I'm stuck on this problem any one know the answer.

**Write a query that displays the grade of all employees based on the value of the column JOB,
as per the table shown below. Order the result according to the grade! **

JOB GRADE
PRESIDENT A
MANAGER B
ANALYST C
SALESMAN D
CLERK E
None of them above O

This should be the output

JOB G
--------- -
PRESIDENT A
MANAGER B
MANAGER B
MANAGER B
ANALYST C
ANALYST C
SALESMAN D
etc.

The database I'm using is EMP and JOB is a column within EMP

SELECT JOB, GRADE FROM EMP 
 WHERE GRADE <= 'O'
 ORDER BY GRADE

I figured it out, but just to let you know grade wasn't a column

select JOB, 
case JOB 
when 'PRESIDENT' then 'A' 
when 'MANAGER' then 'B' 
< other when then > 
else 'O' 
end as GRADE 
from EMP 
order by 
case JOB 
when 'PRESIDENT' then 'A' 
when 'MANAGER' then 'B' 
< other when then > 
else 'O' 
end 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.