I have a table as below:
Job Quantity Status
-----------------------
1 100 OK
2 400 HOLD
3 200 HOLD
4 450 OK
5 300
6 500
I would like my result to be shown as below:
Job Quantity Status
----------------------
4 450 OK
2 400 HOLD
1 100 OK
3 200 HOLD
6 500
5 300
I have created this query but it's not working when the table contains data where the status column is null/empty
SELECT
Job,
Quantity,
Status
FROM
myTable
ORDER BY CASE
WHEN QUANTITY >= 400 AND STATUS = 'OK' THEN 1
WHEN QUANTITY >= 400 AND STATUS = 'HOLD' THEN 2
WHEN QUANTITY < 400 AND STATUS = 'OK' THEN 3
WHEN QUANTITY >= 400 AND STATUS = 'HOLD' THEN 4
WHEN QUANTITY >= 400 AND STATUS = '' THEN 5
WHEN QUANTITY < 400 AND STATUS = '' THEN 6
END