The PADS Hackerrank Solution - SQL
For Explanation Watch Video :
Oracle::
SELECT NAME || '(' || SUBSTR(OCCUPATION,1,1) || ')' AS N
FROM OCCUPATIONS
ORDER BY N;
SELECT 'There are a total of ' || COUNT(OCCUPATION) || ' ' || LOWER(OCCUPATION) || 's.'
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY COUNT(OCCUPATION), OCCUPATION;
MySql:
=======
SELECT CONCAT(NAME,'(',SUBSTR(OCCUPATION,1,1),')') AS NA
FROM OCCUPATIONS
ORDER BY NA;
SELECT CONCAT('There are a total of ',COUNT(OCCUPATION),' ',LOWER(OCCUPATION),'s.')
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY COUNT(OCCUPATION), OCCUPATION;
Comments
Post a Comment