검색결과 리스트
Programming/oracle에 해당되는 글 2건
- 2017.09.20 select insert, multiple select query inert
- 2014.03.25 오라클(ORACLE) 그룹별 채번
글
select insert, multiple select query inert
Programming/oracle
2017. 9. 20. 10:53
insert into table(id, name, `time`)
select id,'max_val', `time` from table_b where id= 1234 order by avg_value desc limit 1
괄호 해도되고 안해도 되고
insert into table(id, name, `time`)
(select id,'max_val', `time` from table_b where id= 1234 order by avg_value desc limit 1)
이게 아니고 다중 select문을 insert 하고 싶다.
insert into table(id, name, `time`)
(select id,'max_val', `time` from table_b where id= 1234 order by avg_value desc limit 1)
union all
(select id,'min_val', `time` from table_b where id= 1234 order by avg_value asc limit 1)
union : 중복제거 느림
union all : 중복제거안함 빠름
생각해보면 간단하구나..
'Programming > oracle' 카테고리의 다른 글
| 오라클(ORACLE) 그룹별 채번 (0) | 2014.03.25 |
|---|
글
오라클(ORACLE) 그룹별 채번
Programming/oracle
2014. 3. 25. 05:03
1. ROW_NUMBER() OVER (PARTITION BY 그룹핑할컬럼 ORDER BY 정렬컬럼)
그룹 단위로 증가하는 번호를 매긴다
EX)
A1 1
A1 2
A2 1
A2 2
A2 3
2. DENSE_RANK() OVER (ORDER BY 기준컬럼)
그룹번호를 매긴다. 정확히 말하면 정렬해서 랭킹을 매기기
EX)
A1 1
A1 1
A2 2
A2 2
A2 3
찾기힘들어서 적어둠!!!둠둠~
'Programming > oracle' 카테고리의 다른 글
| select insert, multiple select query inert (0) | 2017.09.20 |
|---|