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.
- Prepare
- SQL
- Advanced Select
- The PADS
- Discussions
The PADS
The PADS
Sort by
recency
|
5702 Discussions
|
Please Login in order to post a comment
Nice problem for beginners learning SQL formatting. Using functions to extract the first letter of the occupation and ordering the results correctly is the key part. Overall, it’s a clean and interesting practice exercise. @Dinosaur Game
SELECT CONCAT(NAME,"(",(SELECT LEFT(OCCUPATION,1)),")") FROM OCCUPATIONS ORDER BY NAME ASC;
SELECT CONCAT("There are a total of ", COUNT(OCCUPATION)," ", LOWER(OCCUPATION),"s.") FROM OCCUPATIONS GROUP BY(OCCUPATION) ORDER BY COUNT(OCCUPATION) ASC;
SELECT NAME || '(' || SUBSTR(OCCUPATION, 1, 1) || ')' FROM OCCUPATIONS ORDER BY NAME;
SELECT 'There are a total of ' || COUNT(OCCUPATION) || ' ' || LOWER(OCCUPATION) || 's.' FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY COUNT(OCCUPATION) ASC, OCCUPATION ASC;
MySQL: select concat(Name, '(', substring(Occupation,1,1),')') from Occupations order by Name; select concat('There are a total of ',count(),' ',lower(Occupation),'s.') from occupations group by occupation order by count() asc, occupation asc;
In MySQL Server:
SELECT CONCAT(Name, '(', LEFT(Occupation, 1), ')') FROM OCCUPATIONS ORDER BY Name ASC; SELECT CONCAT('There are a total of ', COUNT(Occupation), ' ', LOWER(Occupation), 's.') FROM OCCUPATIONS GROUP BY Occupation ORDER BY COUNT(Occupation) ASC, Occupation ASC;