John Lekberg


JUNTO Practice - "The PADS"

Discussed on 2019-08-15.

The PADS


Solution - Daniel

SELECT CONCAT(Name, '(', LEFT(Occupation,1),')') FROM OCCUPATIONS ORDER BY Name;

SELECT CONCAT('There are a total of ', COUNT(Occupation), ' ', LOWER(Occupation), 's.') FROM OCCUPATIONS GROUP BY Occupation ORDER BY COUNT(Occupation), Occupation;

Solution - John

SELECT name || '(' || SUBSTR(occupation, 1, 1) || ')'
    FROM Occupations
ORDER BY name
;
  SELECT 'There are a total of ' || COUNT(*) || ' '
         || LOWER(occupation) || 's.'
    FROM Occupations
GROUP BY occupation
ORDER BY COUNT(*), occupation
;

Solution - Oscar

SELECT
Name + "(" + SUBSTRING(Occupation,1,1) + ")" as name_occ
FROM
OCCUPATIONS
ORDER BY name_occ;
SELECT
"There are a total of ",
COUNT(*) as occ_count,
LOWER(Occupation) + "s."
FROM
OCCUPATIONS
GROUP BY Occupation
ORDER BY occ_count,Occupation;