Difference between revisions of "CASE STATEMENT"
Jump to navigation
Jump to search
(Created page with "==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...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
==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 = | ==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; | |||
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] | [[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] |
Latest revision as of 20:05, 5 November 2017
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;