1SELECT CASE col1
2 WHEN 'agree' THEN 'Ok'
3 WHEN 'disagree' THEN 'Ko'
4 ELSE
5 CASE
6 WHEN col2 >= 1 THEN 'Ko'
7 ELSE 'Maybe'
8 END
9END AS my_result
10FROM table_name;
1-- Case Eg.) to retrive the MAX value of a Field
2-- if there are entries for the Field in table MAX value will be returned
3-- But if there is no entries at all for the Field in tabel MAX will return
4-- Null as the output. But Using Case When we can check it out return zero
5-- or any other value if there is no enties for the Field in table..
6SELECT
7CASE -- Like Switch Case
8 WHEN -- First When condition
9 (MAX(BILLID) IS NULL) -- Condition
10 THEN 1 -- output (We can also add more When conditions like Above)
11ELSE -- When WHEN Condition not Satisfied Below will be Executed.
12 (MAX(BILLID)) -- output
13END
14as MAXBILLID from DUAL;
15-- Final Output
16-- If there is no entry in the Field for the table
17-- BILLID
18-- 1
19-- If there are entries MAX of that Field value from the table
20-- BILLID
21-- 10