-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkyu7_SQL_with_LOTR_elven_wildcards.sql
More file actions
24 lines (23 loc) · 1.04 KB
/
kyu7_SQL_with_LOTR_elven_wildcards.sql
File metadata and controls
24 lines (23 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- SQL with LOTR: Elven Wildcards;
--
-- https://www.codewars.com/kata/5ad90fb688a0b74111000055
--
-- Deep within the fair realm of Lothlórien, you have been asked to create
-- a shortlist of candidates for a recently vacated position on the council
-- Of so many worthy elves, who to choose for such a lofty position? After much
-- thought you decide to select candidates by name, which are often closely aligned
-- to an elf's skill and temperament
-- Choose those with tegil appearing anywhere in their first name, as they are
-- likely to be good calligraphers, OR those with astar anywhere in their last
-- name, who will be faithful to the role
--
-- Elves table:
-- firstname
-- lastname
--
-- all names are in lowercase
-- To aid the scribes, return the firstname and lastname column concatenated,
-- separated by a space, into a single shortlist column, and capitalise the
-- first letter of each name
SELECT concat_ws(' ', initcap(firstname), initcap(lastname)) as shortlist
FROM Elves WHERE firstname LIKE '%tegil%' OR lastname LIKE '%astar%';