1) 집계함수
- count / sum / avg/ min / max
2) sample의 행의 개수 구하기
select count(*) from sample;
select count(*) from sample where name = 'B';
3) distinct로 중복 제거
select distinct name from sample;
select count(all name), count(distinct name) from sample;
4) sum으로 합계 구하기
select sum(quantity) from smaple
5) avg로 평균값 구하기
select avg(quantity), sum(quantity)/count(quantity) from sample;
6) min, max로 최솟값, 최댓값 구하기
select min(quantity), max(quantity), min(name), max(name) from sample;
'Geo-Spatial Data Analysis > SQL' 카테고리의 다른 글
[MySQL] Oracle rownum, mysql에서 사용하기 (0) | 2023.01.12 |
---|---|
[SQL] GROUP BY, HAVING (0) | 2023.01.12 |
[MySQL] Table, Column, Primary key, Foreign key 설정 예시 (0) | 2023.01.11 |
[MySQL] Spatial data 입력 (0) | 2023.01.11 |
[SQL] INSERT, DELETE, UPDATE (0) | 2023.01.11 |