ID | Date | Status | Physician ID
44397479 10/13/2009 17:40 NOSHOW
44397480 10/13/2009 16:40 CHECKED OUT 108
44397481 10/13/2009 14:32 CHECKED OUT 108
44397482 10/14/2009 10:44 RESCHEDULED 108
44397483 8/26/2009 12:35 RESCHEDULED 108
44397484 10/13/2009 15:26 CHECKED OUT 108
56084463 10/10/2009 10:00 PENDING 108
56287658 10/14/2009 10:44 PENDING 108
54728032 10/13/2009 15:56 CHECKED OUT 108
This is a sample from a table contains millions of records.
I need to write a query that will count any two rows that:
- Contain the same Time (only time, not date)
- The status of one of them is "RESCHEDULED" and the other is "PENDING"
will count the two rows as one row only (in the SUM function) for each Physician.
I tried to write it but I couldn't - can you help me please?