Skip to content

Commit bc8cda1

Browse files
authored
Create the_pads.sql
1 parent 7e6500a commit bc8cda1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hackerrank_sql_practice/the_pads.sql

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
3+
Generate the following two result sets:
4+
5+
Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed
6+
by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses).
7+
For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S).
8+
Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences
9+
in ascending order, and output them in the following format:
10+
11+
*/
12+
13+
14+
select concat(name, '(', substring(occupation,1,1 ), ')' ) from occupations order by name ;
15+
16+
select concat('There are a total of ', r ,' ',lcase(occupation), 's.') from (
17+
select occupation, count(occupation) as r from occupations group by occupation )k order by r;

0 commit comments

Comments
 (0)