DataSEA- Data Science, Engineering, Analytics

  # DataSEA: The Gamified Mobile App to Learn Data Engineering, SQL, and Analytics in 10 Minutes a Day                                                                                                                                                                                                             > **TL;DR** — DataSEA is a free Android app that turns Data Engineering, Analytics, and Data Science into bite-size, gamified lessons. 88+ modules,     500+ lessons,...

Order of SQL query execution

 In SQL, the order you write the clauses in a query is not the same as the order in which the database engine executes them.

Here’s the logical order of execution of SQL clauses:

Step

Clause

Description

1️⃣

FROM

Identifies source tables and joins data.

2️⃣

WHERE

Filters rows before grouping.

3️⃣

GROUP BY

Groups rows based on specified columns.

4️⃣

HAVING

Filters groups after aggregation.

5️⃣

SELECT

Selects columns or expressions to return.

6️⃣

DISTINCT

Removes duplicate rows from the result set.

7️⃣

ORDER BY

Sorts the result set.

8️⃣

LIMIT / OFFSET

Returns a subset of the result (pagination).


EXAMPLE:

SELECT department, COUNT(*) AS employee_count
FROM employees
WHERE status = 'active'
GROUP BY department
HAVING COUNT(*) > 10
ORDER BY employee_count DESC
LIMIT 5;


Execution order:

  1. FROM employees

  2. WHERE status = 'active'

  3. GROUP BY department

  4. HAVING COUNT(*) > 10

  5. SELECT department, COUNT(*) AS employee_count

  6. ORDER BY employee_count DESC

  7. LIMIT 5

Comments

Popular posts from this blog

Bhakti-Aarti- Android app Privacy policy

DBT tool connect Athena from Local- AWS SSO

AWS Lake formation - AWS LF - Governance Security- Access control