CREATED_DATE | ENTITY_ID | TYPE
02-MAY-17 | 1234 | A
03-MAY-17 | 1234 | B
04-MAY-17 | 1234 | B
05-MAY-17 | 1234 | B
I'm trying to write a query that will return:
ENTITY_ID | DIFF_BETWEEN_A_B1 | DIFF_BETWEEN_A_B2
1234 | 1 | 2
...
I'm trying to write a query that will show the time it took between getting the first TYPE A record and the first TYPE B record, and the first TYPE A record and the second TYPE B record, for each ENTITY_ID. There will be more than 2 Type B records but only one TYPE A record. I was thinking there might be an efficient way to do this with window functions, but haven't played with those too much. How would you write this?
