Hi I am trying to find the date difference between different rows with like IDs. Please see screenshot of Excel to see data needs clearly. Also screen shots attached from SQL transforms.
SQL Does Validate: Transform 1
SELECT sp_palapprovals_workflow_history_dwb1. *,
Case when (`Primary Item ID`=`Primary Item ID`) and (`Workflow Association Name` like 'Approval') and (`Event Type` like '1') then `Created`
else ' '
end as 'Start Date of Approval'
from sp_palapprovals_workflow_history_dwb1
SQL Does Validate: Transform 2
SELECT start_of_approval. *,
Case when (`Primary Item ID`=`Primary Item ID`) and (`Workflow Association Name` like 'Approval') and (`Event Type` like '2') then `Created`
else ' '
end as 'End Date of Approval'
from start_of_approval
Not Validating........
SELECT end_of_approval.*,
Case when ((`Primary Item ID`=`Primary Item ID`) and (`Start Date of Approval` IS NOT NULL) and (`Start Date of Approval` !='') and (`Start Date of Approval` !=0) and (`End Date of Approval` IS NOT NULL) and (`End Date of Approval` !='') and (`End Date of Approval` !=0))
then (datediff(`End Date of Approval`,`Start Date of Approval`)) - ((week(`End Date of Approval`) - week(`Start Date of Approval`))*2)
else ''
end as 'Date Difference'
from end_of_approval
I did notice The Primary Item ID is not in order in the data set so they are not grouped up in order.... So I tried this first but could not get it to validate either.
Select sp_palapprovals_workflow_history_dwb1.*,
ORDER BY `Primary Item ID`
end
from sp_palapprovals_workflow_history_dwb1
I may be thinking about this problem incorrectly..... Any help would be welcomed.