목록SQL (3)
Data Blog
[문법 순서] SELECT -> FROM -> WHERE -> GROUP BY -> HAVING -> ORDER BY [실행 순서] FROM - > ON -> JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT -> DISTINCT -> ORDER BY FROM : 조회 테이블 확인 ON : 조인 조건 확인 JOIN : 테이블 조인 (병합) WHERE : 데이터 추출 조건 확인 GROUP BY : 특정 컬럼 그룹화 HAVING : 그룹화 이후 데이터 추출 조건 SELECT : 데이터 추출 DISTINCT : 중복 제거 ORDER BY : 데이터 순서 정렬 Alias(별칭)은 FROM, SELECT, ORDER BY절에서만 사용 가능 [출처](https://soo-vely-d..
모든 데이터 조회하기 select * from points 일부 데이터 조회하기 select * from points where quartet = "I" 데이터 정렬하기 select * from points where 1 = 1 and quartet = "I" order by y 데이터 그룹으로 묶기 select quartet, round(avg(x),2) as x_mean, round(variance(x),2) as x_var, round(avg(y),2) as y_mean, round(variance(y),2) as y_var from points where 1 = 1 group by quartet 두 테이블 결합하기 SELECT r.ATHLETE_ID FROM RECORDS r left join E..
select store_id, count( case when active = 1 then customer_id else null end ) as active, count( case when active = 0 then customer_id else null end ) as inactive from customer group by store_id order by store_id solvesql 지역별 주문의 특징 select Region as 'Region', count(distinct case when category ='Furniture' then order_id else null end) as Furniture, count(distinct case when category ='Office Suppli..