We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
MySQL:
select
case
when occupation = 'Doctor' then concat(name,'(D)')
when occupation = 'Actor' then concat(name,'(A)')
when occupation = 'Professor' then concat(name,'(P)')
when occupation = 'Singer' then concat(name,'(S)')
end
from occupations
order by name;
select
case
when occupation = 'Doctor' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.')
when occupation = 'Actor' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.')
when occupation = 'Professor' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.')
when occupation = 'Singer' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.')
end
from occupations
group by occupation
order by count(occupation),occupation;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The PADS
You are viewing a single comment's thread. Return to all comments →
MySQL: select case when occupation = 'Doctor' then concat(name,'(D)') when occupation = 'Actor' then concat(name,'(A)') when occupation = 'Professor' then concat(name,'(P)') when occupation = 'Singer' then concat(name,'(S)') end from occupations order by name; select case when occupation = 'Doctor' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.') when occupation = 'Actor' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.') when occupation = 'Professor' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.') when occupation = 'Singer' then concat('There are a total of ',count(occupation),' ',lower(occupation),'s.') end from occupations group by occupation order by count(occupation),occupation;