-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOccupations.sql
More file actions
19 lines (18 loc) · 694 Bytes
/
Occupations.sql
File metadata and controls
19 lines (18 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Author: Thomas George Thomas
set @d=0, @p=0, @s=0, @a=0;
select min(Doctor), min(Professor), min(Singer), min(Actor)
from(
select case
when Occupation='Doctor' then (@d:=@d+1)
when Occupation='Professor' then (@p:=@p+1)
when Occupation='Singer' then (@s:=@s+1)
when Occupation='Actor' then (@a:=@a+1)
end as Row,
case when Occupation='Doctor' then Name end as Doctor,
case when Occupation='Professor' then Name end as Professor,
case when Occupation='Singer' then Name end as Singer,
case when Occupation='Actor' then Name end as Actor
from OCCUPATIONS
order by Name
) as temp
group by Row;