-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday-23.sql
More file actions
23 lines (20 loc) · 809 Bytes
/
day-23.sql
File metadata and controls
23 lines (20 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- SQL Advent Calendar - Day 23
-- Title: Gingerbread House Top Builders
-- Difficulty: medium
--
-- Question:
-- The Gingerbread House Competition wants to feature the top 3 builders who used the most distinct candy types in their designs. How would you find the builders with the highest count of unique candies, and return only the top three?
--
-- The Gingerbread House Competition wants to feature the builders who used at least 4 distinct candy types in their designs. How would you identify these builders?
--
-- Table Schema:
-- Table: gingerbread_designs
-- builder_id: INT
-- builder_name: VARCHAR
-- candy_type: VARCHAR
--
-- My Solution:
select builder_name, COUNT(distinct candy_type) as unique_candy
from gingerbread_designs
group by builder_name
having COUNT(distinct candy_type) >= 4