Skip to Content
고급 Snowflake
book

고급 Snowflake

by Muhammad Fasih Ullah
September 2025
Beginner to intermediate
210 pages
3h 30m
Korean
O'Reilly Media, Inc.
Content preview from 고급 Snowflake

3장. Snowflake SQL

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

이 장에서는 몇 가지 고급 Snowflake SQL 함수를 살펴보겠습니다. 먼저 Snowflake의 실행 순서부터 살펴본 다음, 다른 Windows 함수로 이동하여 어디에서 사용할 수 있는지 살펴보겠습니다. 그 다음에는 Snowflake의 지리공간 함수에 대해 알아보겠습니다.

실행 순서

Snowflake는 SQL 절의 매우 논리적인 실행 순서를 따릅니다. 그러나 QUALIFY 절이 도입되면서 상황이 조금 흥미로워졌습니다. Windows 함수와 QUALIFY 을 사용하는 많은 Snowflake 사용자들은 무엇이 언제 실행되는지, 그리고 그것이 쿼리 결과에 어떤 영향을 미치는지에 대해 혼란스러워했습니다. 본질적으로 QUALIFY 절은 데이터를 필터링한다는 점에서 WHERE 절과 매우 유사합니다. 그러나 실행 순서로 보면 QUALIFY 절은 다르므로 혼란이 발생합니다. Snowflake는 다음 순서로 SQL 절을 실행합니다:

  1. FROM

  2. WHERE

  3. GROUP BY

  4. HAVING

  5. WINDOW

  6. QUALIFY

  7. DISTINCT

  8. ORDER BY

  9. LIMIT

다음 쿼리를 실행하면 어떤 일이 발생하는지 살펴보겠습니다:

SELECT *
FROM legends
WHERE first_name = 'Cristiano'
   AND last_name = 'Ronaldo';

이것은 매우 간단한 WHERE 절로 세부 정보를 추출하는 간단한 쿼리입니다. 이 경우, Snowflake는 FROM 절을 먼저 실행하여 어떤 테이블에서 데이터를 읽을지 Snowflake에게 알려줍니다. 그런 다음 WHERE 절을 실행하여 어떤 데이터를 필터링할지, 다시 말해 어떤 마이크로 파티션을 읽을지, 어떤 파티션을 건너뛸지 알려줍니다.

GROUP BYHAVING 절로 넘어가겠습니다. GROUP BY 은 필터링된 데이터의 WHERE 절 뒤에 실행되며 데이터를 집계하는 데 사용됩니다. HAVING 절은 GROUP BY 절의 결과를 필터링하는 데 도움이 됩니다. 수천 명의 직원, 부서 및 $100에서 $5,000까지의 급여에 대한 기록이 포함된 Employees 이라는 테이블이 있다고 가정해 보겠습니다.

표 3-1에서 이 두 쿼리를 살펴보겠습니다.

표 3-1. 실행 순서 (WHEREHAVING)
쿼리 1 쿼리 2
SELECT DEPARTMENT, 
	SUM(SALARY) AS 
	TOTAL_SALARY
FROM EMPLOYEES
GROUP BY DEPARTMENT 
HAVING TOTAL_SALARY < 1000
SELECT DEPARTMENT, 
	SUM(SALARY) AS
	TOTAL_SALARY
FROM EMPLOYEES
WHERE SALARY < 1000 
GROUP BY DEPARTMENT
이 쿼리는 직원 테이블을 읽고 부서별로 그룹화하여 해당 부서의 모든 급여의 합계를 구한 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

効率的なGo ―データ指向によるGoアプリケーションの性能最適化

効率的なGo ―データ指向によるGoアプリケーションの性能最適化

Bartłomiej Płotka, 山口 能迪

Publisher Resources

ISBN: 9798341670983