Skip to Content
ConceptsSQLOverview

SQL (Structured Query Language)

This covers the core principles of SQL, the standard language for communicating with databases.

EssentialInternal

1. Logical Order of Execution

The order in which you write SQL (SELECT -> FROM…) differs from the order in which the database actually executes it. Not knowing this can cause errors.

  1. FROM / JOIN: First, find the tables to retrieve data from.
  2. WHERE: Filter out rows that don’t meet the conditions beforehand. (Performance key)
  3. GROUP BY: Group the remaining data.
  4. HAVING: Keep only groups that satisfy the conditions.
  5. SELECT: Select and calculate the columns to output. (Window Functions happen here too!)
  6. ORDER BY: Sort the results.
  7. LIMIT: Limit the number of results.

Why?: This is why you can’t use an alias created in SELECT in the WHERE clause. WHERE is executed before SELECT!

2. Set Theory

JOIN is based on the concept of sets.

  • INNER JOIN: Intersection (ABA \cap B) - Data that exists in both tables.
  • LEFT JOIN: All of AA + (ABA \cap B) - Keep all from the left, attach from the right if exists.
  • FULL OUTER JOIN: Union (ABA \cup B) - Keep everything from both sides.
  • CROSS JOIN: Cartesian product (A×BA \times B) - All possible combinations (multiply row counts).

Curriculum

1. JOIN (Table Combination)

Learn how to combine multiple tables to extract meaningful data.

2. NULL Handling

Learn how to safely handle NULL values, the biggest enemy in data analysis.

3. String Functions

Learn how to cut, concatenate, and transform text data.

4. Date/Time Functions

Learn the basics of time series analysis: DATE and TIMESTAMP handling.

5. Aggregation and Grouping

Learn GROUP BY techniques to summarize data and gain insights.

6. Window Functions (Advanced)

Learn window functions, the flower of SQL, for calculating relationships between rows.

7. CTE (Common Table Expression)

A readability technique for writing complex queries like building with Lego blocks.

Last updated on

🤖AI 모의면접실전처럼 연습하기