반응형
SELECT *
FROM fruit_imports
SELECT state
FROM fruit_imports
GROUP BY state
ORDER BY SUM(supply) DESC
LIMIT 1
SELECT season, MAX(cost_per_unit) highest_cost_per_unit
FROM fruit_imports
GROUP BY season
ORDER BY MAX(cost_per_unit) DESC
SELECT state
FROM fruit_imports
GROUP BY state, name
HAVING count(name) > 1
SELECT season, count(*)
FROM fruit_imports
GROUP BY season
HAVING count(*) = 3 or count(*) = 4
SELECT state, SUM(supply * cost_per_unit) total_cost
FROM fruit_imports
GROUP BY state
ORDER BY total_cost desc
LIMIT 1
SELECT *
FROM fruits
SELECT COUNT(COALESCE(fruit_name, 'SOMEVALUE'))
FROM fruits
반응형
'Work | 업무 > 데이터분석' 카테고리의 다른 글
[SQL 스터디] 9일차 서브쿼리1 (0) | 2020.03.11 |
---|---|
[SQL 스터디] 7일차 GROUPING, GROUP BY, HAVING (0) | 2020.03.08 |
[SQL 스터디] 6일차 Grouping functions: MAX(), MIN(), AVG(), COUNT(), SUM() (0) | 2020.03.06 |
댓글