Skip to content

Commit ebeeea4

Browse files
committed
Solvesql Solution
- SQL
1 parent 705100b commit ebeeea4

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- @ss.idx: 22
2+
-- @ss.level: 2
3+
-- @ss.title: 한국 감독의 영화 찾기
4+
-- @ss.slug: find-movies-by-korean-artists
5+
-- @ss.category: JOIN/UNION
6+
-- @ss.note:
7+
8+
SELECT at.name as artist
9+
, a.title
10+
FROM artworks a
11+
JOIN artworks_artists aa ON a.artwork_id = aa.artwork_id
12+
JOIN artists at ON aa.artist_id = at.artist_id
13+
WHERE at.nationality = 'Korean'
14+
AND a.classification LIKE 'Film%';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- @ss.idx: 20
2+
-- @ss.level: 2
3+
-- @ss.title: 레스토랑의 주중, 주말 매출액 비교하기
4+
-- @ss.slug: revenue-weekday-weekend
5+
-- @ss.category: CASE/IF
6+
-- @ss.note:
7+
8+
SELECT IF(day IN ('Sat', 'Sun'), 'weekend', 'weekday') AS 'week'
9+
, SUM(total_bill) AS 'sales'
10+
FROM tips
11+
GROUP BY week
12+
ORDER BY sales DESC;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- @ss.idx: 21
2+
-- @ss.level: 2
3+
-- @ss.title: 매출이 높은 배우 찾기
4+
-- @ss.slug: top-revenue-actors
5+
-- @ss.category: JOIN/UNION
6+
-- @ss.note:
7+
8+
SELECT a.first_name
9+
, a.last_name
10+
, temp.total_revenue
11+
FROM actor a
12+
JOIN (
13+
SELECT fa.actor_id
14+
, SUM(p.amount) as total_revenue
15+
FROM film_actor fa
16+
JOIN inventory i ON i.film_id = fa.film_id
17+
JOIN rental r ON r.inventory_id = i.inventory_id
18+
JOIN payment p ON p.rental_id = r.rental_id
19+
GROUP BY fa.actor_id
20+
) AS temp ON a.actor_id = temp.actor_id
21+
ORDER BY temp.total_revenue DESC
22+
LIMIT 5;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- @ss.idx: 23
2+
-- @ss.level: 2
3+
-- @ss.title: 연도별 배송 업체 이용 내역 분석하기
4+
-- @ss.slug: yearly-shipping-usage
5+
-- @ss.category: CASE/IF
6+
-- @ss.note:
7+
8+
SELECT YEAR(purchased_at) AS 'year'
9+
, SUM(shipping_method = 'Standard') + SUM(is_returned) AS 'standard'
10+
, SUM(shipping_method = 'Express') AS 'express'
11+
, SUM(shipping_method = 'Overnight') AS 'overnight'
12+
FROM transactions
13+
WHERE is_online_order = 1
14+
GROUP BY YEAR(purchased_at)
15+
ORDER BY year;

0 commit comments

Comments
 (0)