Sequence of SQL calculation

2022. 5. 20. 07:50데이터 분석가로 살기

1. Single Query


2. Multiple tables


3. Hence,
- when you need single values or list, it would be more efficient executing in a single table than using several ctes
- focus on Where and Select stages as following :

Example 1:
select customer_id, cost
from Customer
where customer_id in (select customer_id from Customer)

Example 2:
select purchase_amount >(select avg(purchase_amount) from Customer)
from Customer
where customer_id in

Source : https://medium.com/@Hong_Tang/my-secret-recipe-for-sql-query-f43492e5f4f0