How to Calculate Date Difference
Hi,
What's the best way in SQL to calculation date difference from one status to status.
Let say,
OLD_VAL = Null NEW_VAL = Created DATE = 01/01/2011
OLD_VAL = Created NEW_VAL = Prospect DATE = 01/31/2011
Desired results would be:
Name Begin Status End Status Begin Date End Date Total Handling Time
Account1 Null Created 01/01/2011 01/01/2011 0
Account1 Created Prospect 01/01/2011 01/31/2011 31
Sample SQL and generated results below:
SELECT OPERATION_DT, CA.OLD_VAL,CA.NEW_VAL, SP.NAME
What's the best way in SQL to calculation date difference from one status to status.
Let say,
OLD_VAL = Null NEW_VAL = Created DATE = 01/01/2011
OLD_VAL = Created NEW_VAL = Prospect DATE = 01/31/2011
Desired results would be:
Name Begin Status End Status Begin Date End Date Total Handling Time
Account1 Null Created 01/01/2011 01/01/2011 0
Account1 Created Prospect 01/01/2011 01/31/2011 31
Sample SQL and generated results below:
SELECT OPERATION_DT, CA.OLD_VAL,CA.NEW_VAL, SP.NAME
FROM SIEBEL.CX_AUDIT_ITEM CA
JOIN SIEBEL.S_PARTY SP ON CA.RECORD_ID = SP.ROW_IDLEFT JOIN SIEBEL.S_ORG_EXT SO ON SO.ROW_ID = SP.ROW_ID
0