Hi there.. I've been struggling with this and I hope one of you experts can help me out. I'm trying to get a query that will return the first and last values based on date and order id
I have a source table that looks like this
ID | Order ID | Date & Time | Start | Current
---------------------------------------------------------
01 | 0x0000000001 | 10-10-02 06:00:00 | 80.00 | 80.00
02 | 0x0000000001 | 10-10-02 07:00:00 | 80.00 | 70.00
03 | 0x0000000001 | 10-10-02 08:00:00 | 80.00 | 60.00
04 | 0x0000000002 | 10-10-02 06:00:00 | 80.00 | 50.00
05 | 0x0000000003 | 10-10-02 06:00:00 | 80.00 | 40.00
06 | 0x0000000001 | 10-10-02 11:00:00 | 80.00 | 30.00
And I would like it the results to be
ID | Order ID | Date & Time | Start | Current
---------------------------------------------------------
01 | 0x0000000001 | 10-10-02 06:00:00 | 80.00 | 80.00
04 | 0x0000000002 | 10-10-02 06:00:00 | 80.00 | 50.00
05 | 0x0000000003 | 10-10-02 06:00:00 | 80.00 | 40.00
06 | 0x0000000001 | 10-10-02 11:00:00 | 80.00 | 30.00
Note, this include rows 4 and 5 that have only one record (would be fine to have duplicates for those too)
I have a source table that looks like this
ID | Order ID | Date & Time | Start | Current
---------------------------------------------------------
01 | 0x0000000001 | 10-10-02 06:00:00 | 80.00 | 80.00
02 | 0x0000000001 | 10-10-02 07:00:00 | 80.00 | 70.00
03 | 0x0000000001 | 10-10-02 08:00:00 | 80.00 | 60.00
04 | 0x0000000002 | 10-10-02 06:00:00 | 80.00 | 50.00
05 | 0x0000000003 | 10-10-02 06:00:00 | 80.00 | 40.00
06 | 0x0000000001 | 10-10-02 11:00:00 | 80.00 | 30.00
And I would like it the results to be
ID | Order ID | Date & Time | Start | Current
---------------------------------------------------------
01 | 0x0000000001 | 10-10-02 06:00:00 | 80.00 | 80.00
04 | 0x0000000002 | 10-10-02 06:00:00 | 80.00 | 50.00
05 | 0x0000000003 | 10-10-02 06:00:00 | 80.00 | 40.00
06 | 0x0000000001 | 10-10-02 11:00:00 | 80.00 | 30.00
Note, this include rows 4 and 5 that have only one record (would be fine to have duplicates for those too)