Hi, I have a complex sorting problem with my SQL statement. I have a table with the following columns.
No Time Value
-- ---- -----
1 0900 ''
2 1030 ''
3 1020 ''
4 1010 ''
5 1100 ''
1 1015 'P'
2 1045 'P'
I want to sort this table by doing the following steps.
Select rows from the table where Value is '' (empty string) and sort it by No.
Select rows from the same table where Value is 'P' and then sort it by time.
Select each row from 2) and insert into 1) by time.
The result should be something like this.
No Time Value
-- ---- -----
1 0900 ''
1 1015 'P'
2 1030 ''
3 1020 ''
4 1010 ''
2 1045 'P'
5 1100 ''
How can I do this in SQL?