add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE test (name VARCHAR(255), status VARCHAR(255), price INT);
INSERT INTO test
WITH cte AS ( SELECT 'item1', 'active', 4 FROM DUAL UNION ALL
SELECT 'item2', 'inactive', 5 FROM DUAL UNION ALL
SELECT 'item3', 'active', 4 FROM DUAL UNION ALL
SELECT 'item4', 'cancelled', 3 FROM DUAL UNION ALL
SELECT 'item5', 'cancelled', 2 FROM DUAL UNION ALL
SELECT 'item6', 'inactive', 4 FROM DUAL )
SELECT * FROM cte;
6 rows affected
SELECT *
FROM test;
NAME STATUS PRICE
item1 active 4
item2 inactive 5
item3 active 4
item4 cancelled 3
item5 cancelled 2
item6 inactive 4
SELECT *
FROM test
ORDER BY CASE status WHEN 'cancelled'
THEN 1
ELSE 2
END;
NAME STATUS PRICE
item5 cancelled 2
item4 cancelled 3
item6 inactive 4
item2 inactive 5
item1 active 4
item3 active 4