반응형
SELECT DEPTNO, SAL FROM emp;
SELECT DEPTNO, SUM(SAL) FROM emp GROUP BY DEPTNO;
SELECT deptno, sal, ROWNUM
from(
SELECT DEPTNO,sal FROM emp ORDER BY deptno, sal DESC)
WHERE DEPTNO = 10
UNION ALL
SELECT deptno, sal, ROWNUM
from(
SELECT DEPTNO,sal FROM emp ORDER BY deptno, sal DESC)
WHERE deptno = 20
UNION ALL
SELECT deptno, sal, ROWNUM
from(
SELECT DEPTNO,sal FROM emp ORDER BY deptno, sal DESC)
WHERE deptno = 30;
년도별 학생들의 키 순위
select name,birthday,height, ROWNUM FROM(
select * from student)
where SUBSTR(birthday,0,4) = 1975
UNION ALL
select name,birthday,height, ROWNUM FROM(
select * from student)
where SUBSTR(birthday,0,4) = 1976
UNION ALL
select name,birthday,height, ROWNUM FROM(
select * from student)
where SUBSTR(birthday,0,4) = 1977
UNION ALL
select name, birthday,height, ROWNUM FROM(
select * from student)
where SUBSTR(birthday,0,4) = 1978;
PARTITION BY
select * from emp;
select deptno,sal, sum(sal) OVER (PARTITION BY deptno ORDER BY sal_order DESC)
from(select deptno, sal,ROW_NUMBER() OVER (ORDER BY sal) sal_order
from emp);
'정리' 카테고리의 다른 글
데이터베이스 피벗 사용해보기 (0) | 2020.02.26 |
---|---|
추상클래스와 인터페이스의 차이점 (0) | 2020.02.25 |
데이터베이스 실행 순서 (0) | 2020.02.24 |
(flutter) 테마지정 (0) | 2020.02.20 |
(플러터) 실로폰 (0) | 2020.02.20 |