목록SQL/tips (2)
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 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..