Write PL/SQL to create a calculator by different procedures of various arithmetic operations using a case statements.
Answers
Answered by
0
Answer:
In Oracle string literals need to be surrounded in single quotes.
To find a sub-string match you can either use LIKE:
SELECT ID,
NAME,
CASE WHEN Descr LIKE '%Test%' THEN 'Contains Test'
WHEN Descr LIKE '%Other%' THEN 'Contains Other'
ELSE 'No Match'
END AS Match
FROM Item i
LEFT OUTER JOIN
Description d
ON i.id = d.item_id
or INSTR():
SELECT ID,
NAME,
CASE WHEN INSTR( Descr, 'Test' ) > 0 THEN 'Contains Test'
WHEN INSTR( Descr, 'Other' ) > 0 THEN 'Contains Other'
ELSE 'No Match'
END AS Match
FROM Item i
LEFT OUTER JOIN
Description d
ON i.id = d.item_id
Similar questions