I have a difficult sorting problem with my SQL operation. 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 following these steps.
Select the rows from the table, where Value is the value '' (empty row) and sort it by number.
Select the 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 to do it in SQL?
source
share