-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThe PADS.sql
33 lines (26 loc) · 839 Bytes
/
The PADS.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- # Problem: https://www.hackerrank.com/challenges/the-pads/problem
-- # Solution 1
SELECT CONCAT(NAME, '', '(' , LEFT(OCCUPATION, 1) , ')')
FROM OCCUPATIONS
ORDER BY NAME;
SELECT CONCAT('There are a total of ', COUNT(NAME), ' doctors.')
FROM OCCUPATIONS
WHERE OCCUPATION = 'Doctor';
SELECT CONCAT('There are a total of ', COUNT(NAME), ' actors.')
FROM OCCUPATIONS
WHERE OCCUPATION = 'Actor';
SELECT CONCAT('There are a total of ', COUNT(NAME), ' singers.')
FROM OCCUPATIONS
WHERE OCCUPATION = 'Singer';
SELECT COUNT(NAME)
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY NAME ASC;
-- # Solution 2
SELECT CONCAT(NAME, '', '(' , LEFT(OCCUPATION, 1) , ')')
FROM OCCUPATIONS
ORDER BY NAME;
SELECT CONCAT('There are a total of ', COUNT(NAME), ' ', LOWER(OCCUPATION), 's.')
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY COUNT(NAME) ASC;