SELECT last_name, job_id, salary,
(CASE
WHEN job_id LIKE 'SA_MAN' AND salary < 12000 THEN '10%'
WHEN job_id LIKE 'SA_MAN' AND salary >= 12000 THEN '15%'
WHEN job_id LIKE 'IT_PROG' AND salary < 9000 THEN '8%'
WHEN job_id LIKE 'IT_PROG' AND salary >= 9000 THEN '12%'
ELSE 'NOT APPLICABLE'
END ) Raise
FROM employees;
Read more on CASE:
Use a CASE
Statement in Oracle SQL
This assignment will ask you to
modify an existing report to use the CASE statement. Your
assignment is to use a CASE statement as follows:
* CASE 1: Books with total sales
greater than $100,000, display “Best Seller”
* CASE 2: Books with total sales
between $10,000 and $99,999 display “Average Seller”
* CASE 3: Books with sales less than
$10,000 display “Poor Seller”
ANSWER:
col
store_name format a25
col book_title format a25
col
total_sales format $999,999
col sales format a15
break on sales
skip 2
select
(case
when
sum(quantity)*book_retail_price > 100000 then 'Best Seller'
when sum(quantity)*book_retail_price < 10000 then 'Poor
Seller'
else 'Average Seller'
end ) sales,
store_name,
book_title,
sum(quantity)*book_retail_price
total_sales
from
store,
sales,
book
where
store.store_key = sales.store_key
and
sales.book_key = book.book_key
group by
store_name,
book_title,
book_retail_price
order by
total_sales
desc
;