-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThe PADS.sql
More file actions
21 lines (16 loc) · 1.14 KB
/
The PADS.sql
File metadata and controls
21 lines (16 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
Enter your query here.
Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
Generate the following two result sets:
Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S).
Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format:
There are a total of [occupation_count] [occupation]s.
where [occupation_count] is the number of occurrences of an occupation in OCCUPATIONS and [occupation] is the lowercase occupation name. If more than one Occupation has the same [occupation_count], they should be ordered alphabetically.
*/
SELECT CONCAT(NAME, '(', (LEFT(OCCUPATION, 1)), ')')
FROM OCCUPATIONS
ORDER BY NAME ASC;
SELECT CONCAT('There are a total of ',CAST(COUNT(OCCUPATION) AS VARCHAR(10)), ' ', LOWER(OCCUPATION), 's.')
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY COUNT(OCCUPATION) ASC, OCCUPATION ASC;