-
Notifications
You must be signed in to change notification settings - Fork 24
/
the-pads.sql
34 lines (30 loc) · 981 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
34
-- SQL > Advanced Select > The PADS
-- Query the name and abbreviated occupation for each person in OCCUPATIONS.
--
-- https://www.hackerrank.com/challenges/the-pads/problem
-- https://www.hackerrank.com/contests/simply-sql/challenges/the-pads
-- challenge id: 12889
--
SET NULL "NULL";
SET FEEDBACK OFF;
SET ECHO OFF;
SET HEADING OFF;
SET WRAP OFF;
SET LINESIZE 10000;
SET TAB OFF;
SET PAGES 0;
SET DEFINE OFF;
-- (skeliton_head) ----------------------------------------------------------------------
select concat(name,
concat('(',
concat(substr(occupation, 1, 1), ')')))
from occupations
order by name;
select concat('There are a total of ',
concat(count(name),
concat(' ',
concat(lower(occupation), 's.'))))
from occupations group by occupation
order by count(name), occupation;
-- (skeliton_tail) ----------------------------------------------------------------------
exit;