1. 세로 연산의 원리
그룹핑 예시2. 그룹함수
전체행을 세로연산 하려면 무엇을 써? - sum, max, min, count, avg(그룹함수)
- 평균
select avg(height)
from student;- 갯수 (몇 개 있는지)
select count(height)
from student;- 더하기
select sum(height)
from student;- 최소값
select min(height)
from student;- 최대값
select max(height)
from student;특정 행동, 그룹을 세로연산 하려면 무엇을 써? - where과 그룹함수
select avg(weight)
from student
where year(birthday) = 1975;
select floor(avg(pay))
from professor
where position = "정교수";
select avg(height)
from student;그룹별로 세로연산 하려면 무엇을 써? - group by 그룹함수
Group by,
Union All : 행을 이어주는 역할을 한다
select avg(sal), deptno -- 동일하면 출력가능
from emp
where deptno = "20";
select avg(sal), deptno
from emp
where deptno = 10
union all
select avg(sal), deptno
where deptno = 20
union all
select avg(sal), deptno
from emp
where deptno = 30;
select avg(sal)
from emp
group by deptno;그룹핑 원리 실습
select *
from student;
select avg(height), grade
from student
group by grade;
select job, deptno, avg(sal)
from emp
group by job, deptno;
having deptno !=10 ;

Share article