반응형
데이터 조건은 하나가 아닌 여러개를 담을 수 있다.
그리고 연산, 함수, 개수, 최댓값, 최솟값 수식을 통해 데이터를 추출할 수 있다.
* 조건
SELECT *
FROM 테이블
WHERE
1) 조건 AND 조건: 두 개 모두 충족
2) 조건 OR 조건: 둘 중 하나만 충족
3) NOT 조건: 조건 제외
* 연산자: + - * /
SELECT food_preparation_time,
delivery_time,
food_preparation_time + delivery_time as total_time
FROM food_orders
* 함수: SUM, AVG(컬럼명)
select sum(food_preparation_time) total_food_preparation_time,
avg(delivery_time) avg_food_preparation_time
from food_orders
* 개수: COUNT(컬럼명 or 1 or *)
몇 개의 값을 가지고 있는지: DISTINCT
select count(1) count_of_orders,
count(distinct customer_id) count_of_customers
from food_orders
* 최솟값: MIN(컬럼명)
최댓값: MAX(컬럼명)
select min(price) min_price,
max(price) max_price
from food_orders
반응형
'데이터분석 부트캠프 > SQL' 카테고리의 다른 글
| [데이터분석 부트캠프] SQL #6. PIVOT TABLE, Window Function(RANK, SUM), 날짜 포맷 함수 (0) | 2025.09.30 |
|---|---|
| [데이터분석 부트캠프] SQL #5. JOIN, NULL 제외 (0) | 2025.09.29 |
| [데이터분석 부트캠프] SQL #4. IF, CASE, SUBQUERY (0) | 2025.09.26 |
| [데이터분석 부트캠프] SQL #3. 데이터 그룹, 정렬, REPLACE, SUBSTR, CONCAT (0) | 2025.09.25 |
| [데이터분석 부트캠프] SQL #1. 데이터 추출, 컬럼명 변경, 조건 (0) | 2025.09.23 |