I want to sort the below table XYZ using sql,
here Id is the primary key.
----------------------------------------
Id | Date |Product | Time
----------------------------------------
1 | 01-02-2016 |C |10:00
2 | 01-02-2016 |B |10:30
3 | 01-02-2016 |A |11:00
4 | 01-02-2016 |C |11:30
5 | 01-02-2016 |B |12:00
6 | 01-02-2016 |A |12:30
7 | 01-02-2016 |C |13:00
8 | 01-02-2016 |B |13:30
9 | 02-02-2016 |D |07:00
10 | 02-02-2016 |C |07:30
11 | 02-02-2016 |E |08:00
12 | 02-02-2016 |D |08:30
13 | 02-02-2016 |E |09:00
14 | 02-02-2016 |A |09:30
I need to sort it in such a way to find the Product with the minimum time for each day and sort by time, then the Product with the next earliest time and sort by time in the following manner.
Id |Date |Product |Time
1 |01-02-2016| C |10:00
4 |01-02-2016| C |11:30
7 |01-02-2016| C |13:00
2 |01-02-2016| B |10:30
5 |01-02-2016| B |12:00
8 |01-02-2016| B |13:30
3 |01-02-2016| A |11:00
6 |01-02-2016| A |12:30
9 |02-02-2016| D |07:00
12 |02-02-2016| D |08:30
10 |02-02-2016| C |07:30
11 |02-02-2016| E |08:00
13 |02-02-2016| E |09:00
14 |02-02-2016| A |09:30