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
운영게시판
최근게시물
DB2 Q&A 1788 게시물 읽기
No. 1788
오라클 -> db2변환로 수정하면 어떻게 쿼리가 바뀌는지 도움부탁드려요
작성자
이종국(ljk76)
작성일
2008-12-23 11:42ⓒ
2008-12-23 13:36ⓜ
조회수
10,476

 select regdate, count(*) as count,
 (select count(*) from tbl_count) as count_sum   from
   (select
   case to_char(regdate,'d')
   
   when '1' then 'Mon'
   when '2' then 'Tue'
   when '3' then 'Wed'
   when '4' then 'Thu'
   when '5' then 'Fri'
   when '6' then 'Sat'  
   when '7' then 'Sun'
   end as regdate,        
   to_number(to_char(regdate,'d')) as regdate_num  
   from tbl_count where regdate > to_date('2008-12-01 00:00:00' ,'yyyy-mm-dd hh24:mi:ss')
   and regdate < add_months(to_date('2008-12-01 00:00:00','yyyy-mm-dd hh24:mi:ss'),1)) a 
   group by regdate,regdate_num   order by regdate_num 

이 글에 대한 댓글이 총 1건 있습니다.
 select regdate, count(*) as count,
 (select count(*) from tbl_count) as count_sum  
 from
   (select
   case dayofweek(regdate)
   when 2 then 'Mon'
   when 3 then 'Tue'
   when 4 then 'Wed'
   when 5 then 'Thu'
   when 6 then 'Fri'
   when 7 then 'Sat'  
   when 1 then 'Sun'
   end as regdate,        
   dayofweek(regdate) as regdate_num  
   from tbl_count
   where regdate > to_char('2008-12-01 00:00:00' ,'yyyy-mm-dd hh24:mi:ss')
   and regdate < to_char(timestamp('2008-12-01 00:00:00') + 1 MONTH,'yyyy-mm-dd hh24:mi:ss')) a 
   group by regdate,regdate_num  
   order by regdate_num  

1) to_char(regdate,'d')가 DB2에서는 dayofweek(regdate)로 표현 가능합니다.
    단, 일요일이 1로 표현되며 이는 문자가 아닌 정수입니다.  
2) DB2에서는 to_char가 Oracle의 to_date와 유사합니다.

* 테스트 해보지는 않았는데 이렇게 수정하시면 원하시는 결과값을 얻으실 수 있을듯 싶습니다.
  잘 안되시면 댓글 달아주세요~
HENA님이 2008-12-30 11:00에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
1791sqlcode 질문입니다
김한중
2009-01-06
10829
1790DB2 테이블 , 인덱스여부 어떻게 확인하나요 [1]
택이
2008-12-29
15143
1789With 질문
궁금이
2008-12-24
10256
1788오라클 -> db2변환로 수정하면 어떻게 쿼리가 바뀌는지 도움부탁드려요 [1]
이종국
2008-12-23
10476
1782테이블 정보 보기 [1]
김미홍
2008-12-22
9920
1779DBVisualizer 설치하여 써보신분 !!!!
지원요청
2008-12-18
9032
1778DPF에서 노드수와 파티션수의 확인방법 [1]
dbuser
2008-12-16
10446
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.048초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다