Hi all,
I'm searching for a solution on the following.
In a table I have the following columns:
Row Id - Call Id - Date ---------- Action
001 ------ 230 ---- 10-10-2007 - Logged
002 ------ 230 ---- 10-12-2007 - Closed
003 ------ 230 ---- 10-19-2007 - Reactivated
004 ------ 230 ---- 10-21-2007 - Closed
005 ------ 231 ---- 10-22-2007 - Logged
etc...
row id = unique
Action can be:
- Logged
- Closed
- Reactivated
In this table more actions can be logged on one Call id.
I need a query what calculates the difference in days between logged and (the first following) closed added with the days from (also the first coming) Reactivated untill (the next) closed as long as there are records for that call id.
ordering on row_id will ensure the right order.
I've worked myself to the bone to figure this one out on mssql but can't get there.
I've tried to make a cursor with log and close time in one record, then union it with the reactivated and closed records but I failed to get it work.
Is there anyone who can give me a hand please?
Thanks in advance.
Karsten
I'm searching for a solution on the following.
In a table I have the following columns:
Row Id - Call Id - Date ---------- Action
001 ------ 230 ---- 10-10-2007 - Logged
002 ------ 230 ---- 10-12-2007 - Closed
003 ------ 230 ---- 10-19-2007 - Reactivated
004 ------ 230 ---- 10-21-2007 - Closed
005 ------ 231 ---- 10-22-2007 - Logged
etc...
row id = unique
Action can be:
- Logged
- Closed
- Reactivated
In this table more actions can be logged on one Call id.
I need a query what calculates the difference in days between logged and (the first following) closed added with the days from (also the first coming) Reactivated untill (the next) closed as long as there are records for that call id.
ordering on row_id will ensure the right order.
I've worked myself to the bone to figure this one out on mssql but can't get there.
I've tried to make a cursor with log and close time in one record, then union it with the reactivated and closed records but I failed to get it work.
Is there anyone who can give me a hand please?
Thanks in advance.
Karsten
Comment