database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
ㆍOracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Oracle Q&A 26662 게시물 읽기
No. 26662
toad 7.6으로 쿼리정리하는 기능 있나요?
작성자
최규운
작성일
2006-05-06 11:14
조회수
1,266

남이 짜놓은 쿼리문인대,,,정리하기도 힘드네요...

 

toad 7.6버젼이 있긴한대 쓰지를 안아서 기능을 잘 모르겠네요..

 

쿼리문 정리해 주는 기능이 어느 메뉴에 있나요?

 

select c.bungi, nvl(pho_cnt,0) pho_cnt, nvl(sup_cnt,0) sup_cnt, nvl(usr_cnt,0) usr_cnt, nvl(vst_cnt,0) vst_cnt, nvl(vst_gen,0) vst_gen, nvl(vst_com,0) vst_com from(select a.bungi, pho_cnt, pho_tot, sup_cnt, sup_tot, vst_cnt, vst_gen, vst_com from(select y.bungi bungi, pho_cnt, pho_tot from (select bungi, count(cnt)-1 pho_cnt, max(total) pho_tot from(select subStr(log_date, 1,4) || ceil(subStr(log_date, 6,2)/3) bungi, count(log_id) cnt, decode(count(log_date) ,null,-1,nvl(rownum,-2)) total from apms_web_log group by rollup(subStr(log_date, 1,4) || ceil(subStr(log_date, 6,2)/3), rownum)) group by bungi) x, (select distinct(bungi) bungi from((select subStr(log_date, 1,4) || ceil(subStr(log_date, 6,2)/3) bungi from apms_web_log group by subStr(log_date, 1,4) || ceil(subStr(log_date, 6,2)/3)) union all (select to_char(req_date, 'yyyy') || ceil(to_char(req_date, 'mm')/3) bungi from apms_supply_web) union all (select to_char(today, 'yyyy') || ceil(to_char(today, 'mm')/3) bungi from apms_counter_web)) ) y where x.bungi (+)= y.bungi order by y.bungi) a, (select y.bungi bungi, sup_cnt, sup_tot , vst_cnt, vst_gen, vst_com from (select bungi , count(cnt)-1 sup_cnt, max(total) sup_tot from(select to_char(req_date, 'yyyy') || ceil(to_char(req_date, 'mm')/3) bungi, sum(tcount) cnt, decode(count(req_date) ,null,-1,nvl(rownum,-2)) total from (select * from apms_supply_web ) group by rollup(to_char(req_date, 'yyyy') || ceil(to_char(req_date,'mm')/3),rownum)) group by bungi ) x, (select to_char(today, 'yyyy') || ceil(to_char(today, 'mm')/3) bungi, count(*) vst_cnt, sum(decode(power_id, '4',1,0)) vst_gen, sum(decode(power_id, '3',1,0)) vst_com from apms_counter_web a, apms_usr_web b where a.web_id = b.web_id group by to_char(today, 'yyyy') || ceil(to_char(today, 'mm')/3) )y where y.bungi (+)= x.bungi ) b where b.bungi (+)= a.bungi) c, (select bungi, usr usr_cnt from(select subStr(log_date, 1,4) || ceil(subStr(log_date, 6,2)/3) bungi, count(distinct(web_id)) usr from apms_web_log group by subStr(log_date, 1,4)|| ceil(subStr(log_date, 6,2)/3)) ) d where d.bungi (+)= c.bungi and d.bungi is not null and c.bungi is not null" + ' and ' + WHERE_PART

 

이 글에 대한 댓글이 총 1건 있습니다.

Toad에서는 잘 모르겠네요..

오렌지에는 그 기능이 있어서 혹시나해서 바꿔서 올립니다

 

select c.bungi,
  nvl(pho_cnt, 0) pho_cnt,
  nvl(sup_cnt, 0) sup_cnt,
  nvl(usr_cnt, 0) usr_cnt,
  nvl(vst_cnt, 0) vst_cnt,
  nvl(vst_gen, 0) vst_gen,
  nvl(vst_com, 0) vst_com
from(
    select a.bungi,
      pho_cnt,
      pho_tot,
      sup_cnt,
      sup_tot,
      vst_cnt,
      vst_gen,
      vst_com
    from(
        select y.bungi bungi,
          pho_cnt,
          pho_tot
        from (
            select bungi,
              count(cnt)-1 pho_cnt,
              max(total) pho_tot
            from(
                select subStr(log_date, 1, 4) || ceil(subStr(log_date, 6, 2)/3) bungi,
                  count(log_id) cnt,
                  decode(count(log_date) , null, -1, nvl(rownum, -2)) total
                from apms_web_log
                group by rollup(subStr(log_date, 1, 4) || ceil(subStr(log_date, 6, 2)/3), rownum))
            group by bungi) x,
          (
            select distinct(bungi) bungi
            from((
                    select subStr(log_date, 1, 4) || ceil(subStr(log_date, 6, 2)/3) bungi
                    from apms_web_log
                    group by subStr(log_date, 1, 4) || ceil(subStr(log_date, 6, 2)/3))
                union all (
                    select to_char(req_date, 'yyyy') || ceil(to_char(req_date, 'mm')/3) bungi
                    from apms_supply_web)
                union all (
                    select to_char(today, 'yyyy') || ceil(to_char(today, 'mm')/3) bungi
                    from apms_counter_web)) ) y
        where x.bungi (+)= y.bungi
        order by y.bungi) a,
      (
        select y.bungi bungi,
          sup_cnt,
          sup_tot ,
          vst_cnt,
          vst_gen,
          vst_com
        from (
            select bungi ,
              count(cnt)-1 sup_cnt,
              max(total) sup_tot
            from(
                select to_char(req_date, 'yyyy') || ceil(to_char(req_date, 'mm')/3) bungi,
                  sum(tcount) cnt,
                  decode(count(req_date) , null, -1, nvl(rownum, -2)) total
                from (
                    select *
                    from apms_supply_web )
                group by rollup(to_char(req_date, 'yyyy') || ceil(to_char(req_date, 'mm')/3), rownum))
            group by bungi ) x,
          (
            select to_char(today, 'yyyy') || ceil(to_char(today, 'mm')/3) bungi,
              count(*) vst_cnt,
              sum(decode(power_id, '4', 1, 0)) vst_gen,
              sum(decode(power_id, '3', 1, 0)) vst_com
            from apms_counter_web a,
              apms_usr_web b
            where a.web_id = b.web_id
            group by to_char(today,
                  'yyyy') || ceil(to_char(today, 'mm')/3) )y
        where y.bungi (+)= x.bungi ) b
    where b.bungi (+)= a.bungi) c,
  (
    select bungi,
      usr usr_cnt
    from(
        select subStr(log_date, 1, 4) || ceil(subStr(log_date, 6, 2)/3) bungi,
          count(distinct(web_id)) usr
        from apms_web_log
        group by subStr(log_date, 1, 4)|| ceil(subStr(log_date, 6, 2)/3)) ) d
where d.bungi (+)= c.bungi
  and d.bungi is not null
  and c.bungi is not null" + ' and ' + WHERE_PART

오락흘님이 2006-05-09 15:42에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
26666트리거에서 where문에 만족하는 값이 없는경우... [6]
김종욱
2006-05-07
4006
26665date 형식 비교하는 방법? [2]
이진웅
2006-05-07
3550
266631 [3]
눈을떳다
2006-05-06
3400
26662toad 7.6으로 쿼리정리하는 기능 있나요? [1]
최규운
2006-05-06
1266
26661토드에서 실행계획을 어떻게 볼까요 ?
까먹지마
2006-05-06
1926
26660토드실행하면 이런 에러가?? [1]
김지연
2006-05-06
1402
266591 [2]
눈을떳다
2006-05-06
1191
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다