You have a table with the stationary orders. You need to output a new column in the table with the order priority according to the total sum of money: less than $1000 is Low, from $1000 to $2000 is Medium, and more than $2000 is High.
Enter the following SQL query:
SELECT *, CASE WHEN 'Subtotal' < 1000 THEN "LOW" WHEN 'Subtotal' >= 1000 AND 'Subtotal' < 2000 THEN "MEDIUM" ELSE "HIGH" END AS 'Priority' FROM T1 |
CASE WHEN ... THEN ... ELSE ... END goes through conditions and return a value when the first condition is met.
AS '...' outputs a new 'Priority' column.![]() ![]() ![]() |