CASE STATEMENT

From rbachwiki
Revision as of 20:05, 5 November 2017 by Bacchas (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

THE CASE STATEMENT

EVALUATES A SINGLE EXPRESSION AND COMPARES IT AGAINST SEVERAL POTENTIAL VALUES, OR EVALUATES MULTIPLE BOOLEAN EXPRESSIONS AND CHOOSES THE FIRST ONE THANT IS TRUE. THIS IS EQUAL TO IF THEN ELSE

SELECT ORDER_ID, TOTAL_AMOUNT,
CASE
 WHEN TOTAL_AMOUNT <= 100 THEN 'LOW'
 WHEN TOTAL_AMOUNT < 1000 THEN 'MEDIUM'
 ELSE 'HEIGH'
END AS "AMOUNT BRACKET"
FROM SALES;

Back To Top- Home - Category