I'm having some difficulty with a query and hoping someone out there can provide me with assistance. What I am attempting to do is create one row, per id, and calculate the number of days (excluding gaps)
table_data:
id start_dt end_dt
1 1/23/2004 2/22/2004
1 2/17/2004 3/19/2004
1 4/27/2004 5/27/2004
2 1/23/2004 2/22/2004
2 2/17/2004 3/19/2004
2 4/27/2004 5/27/2004
Assuming that these are continuous, if I calculated the difference (end_dt)-(start_dt) for each row, the summed the column, I would get a result of 91 days. However the result should be 47. (Duplicate days between row 1 & 2, and a gap in days between row 3 and 4)
If anyone could help with me with this I would greatly appreciate it!
table_data:
id start_dt end_dt
1 1/23/2004 2/22/2004
1 2/17/2004 3/19/2004
1 4/27/2004 5/27/2004
2 1/23/2004 2/22/2004
2 2/17/2004 3/19/2004
2 4/27/2004 5/27/2004
Assuming that these are continuous, if I calculated the difference (end_dt)-(start_dt) for each row, the summed the column, I would get a result of 91 days. However the result should be 47. (Duplicate days between row 1 & 2, and a gap in days between row 3 and 4)
If anyone could help with me with this I would greatly appreciate it!