Skip to Content
러닝 SQL: 데이터 생성, 검색, 조작까지 데이터 제대로 주무르기
book

러닝 SQL: 데이터 생성, 검색, 조작까지 데이터 제대로 주무르기

by 류수미, 송희정, 앨런 볼리외
March 2021
Beginner to intermediate
456 pages
12h 49m
Korean
Hanbit Media, Inc.
Content preview from 러닝 SQL: 데이터 생성, 검색, 조작까지 데이터 제대로 주무르기
362
러닝 SQL
| 595 | July | 19 | 5 |
| 469 | July | 18 | 13 |
...
| 457 | May | 1 | 347 |
| 356 | May | 1 | 347 |
| 481 | May | 1 | 347 |
| 10 | May | 1 | 347 |
+-------------+--------------+-------------+----------+
2466 rows in set (0.03 sec)
결과를 보면 매월 순위가
1
로 재설정된 것을 볼 수 있습니다. 마케팅 부서가 원하는 결과 (매월
상위
5
명의 고객 )를 생성하려면 서브쿼리에서 이전 쿼리를 래핑하고 필터조건을 추가하여 순
위가
5
보다 높은 행을 제외하면 됩니다.
SELECT customer_id, rental_month, num_rentals,
rank_rnk ranking
FROM
(SELECT customer_id,
monthname(rental_date) rental_month,
count(*) num_rentals,
rank() over (partition by monthname(rental_date)
order by count(*) desc) rank_rnk
FROM rental
GROUP BY customer_id, monthname(rental_date)
) cust_rankings ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

클라우드 네이티브를 위한 데이터 센터 네트워크 구축: 데이터 센터 네트워킹을 위한 아키텍처, 프로토콜, 도구

클라우드 네이티브를 위한 데이터 센터 네트워크 구축: 데이터 센터 네트워킹을 위한 아키텍처, 프로토콜, 도구

정기훈, 디네시 G. 더트

Publisher Resources

ISBN: 9791162244074