본문 바로가기
Work | 업무/데이터분석

[SQL 스터디] 8일차 섹션4, EXERCISES

by 1theBoy 2020. 3. 10.
반응형

 

 

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

 

반응형

댓글