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 38768 게시물 읽기
No. 38768
캘린터 형태의 예약일정을 표시하려고 하는대 좀 도와주세요...
작성자
박수길(sookill)
작성일
2011-08-10 16:16ⓒ
2011-08-10 16:28ⓜ
조회수
4,949

with tbl as
(
    select '20110801' ymd, 't' gubun, 'input1' title from dual
    union select '20110802' ymd, 'c' gubun, 'input2' title from dual
    union select '20110802' ymd, 't' gubun, 'input3' title from dual
    union select '20110804' ymd, 'c' gubun, 'input4' title from dual
   
) TBL

데이타 테이블은 이런 형태 입니다.

이데이타를 달력 형태로 해서 표시 할려고 합니다. 그렇니가

월                          화                      수       목        금     토       일 

--------------------------------------------------------------------------------

1                            2                       3         4         5         6        7

input1                  input2                          input4

                            input3

-------------------------------------------------------------------------------

8                            9                    10
 -------------------------------------------------------------------------------

이런 모양이로 만들려고 합니다. 일정 관리 형태이지요

달력과 합쳐서 한번에 쿼리 해야 될거 같은대 가능한가요?

 

도와주시면 감사하겠습니다...

 

 

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

 with tbl as 

(
    select '20110801' ymd, 't' gubun, 'input1' title from dual
    union select '20110802' ymd, 'c' gubun, 'input2' title from dual
    union select '20110802' ymd, 't' gubun, 'input3' title from dual
    union select '20110804' ymd, 'c' gubun, 'input4' title from dual
), 
cal as
(
    SELECT ymd - dd + 1 sun, ymd - dd + 2 mon, ymd - dd + 3 tue, ymd - dd + 4 wed,
       ymd - dd + 5 thu, ymd - dd + 6 fri, ymd - dd + 7 sat
  FROM (SELECT     TO_DATE ('20110801', 'yyyymmdd') + 7 * (LEVEL - 1) ymd,
                   TO_CHAR (TO_DATE ('20110801', 'yyyymmdd') + 7 * (LEVEL - 1), 'd') dd
              FROM DUAL
        CONNECT BY LEVEL <= 6)
 WHERE ymd - dd + 1 < ADD_MONTHS (TO_DATE ('20110801', 'yyyymmdd'), 1)
)
 select  max(sun) sun, max(mon) mon, max(tue) tue, max(wed) wed, max(thu) thu, max(fri) fri, max(sat) sat, 
         max(decode(to_date(ymd,'yyyymmdd'),sun, decode(gubun,'t', title))) sun_t,         
         max(decode(to_date(ymd,'yyyymmdd'),mon, decode(gubun,'t', title))) mon_t,         
         max(decode(to_date(ymd,'yyyymmdd'),tue, decode(gubun,'t', title))) tue_t,
         max(decode(to_date(ymd,'yyyymmdd'),wed, decode(gubun,'t', title))) wed_t,
         max(decode(to_date(ymd,'yyyymmdd'),thu, decode(gubun,'t', title))) thu_t,
         max(decode(to_date(ymd,'yyyymmdd'),fri, decode(gubun,'t', title))) fri_t,
         max(decode(to_date(ymd,'yyyymmdd'),sat, decode(gubun,'t', title))) sat_t,
         max(decode(to_date(ymd,'yyyymmdd'),sun, decode(gubun,'c', title))) sun_c,
         max(decode(to_date(ymd,'yyyymmdd'),mon, decode(gubun,'c', title))) mon_c,
         max(decode(to_date(ymd,'yyyymmdd'),tue, decode(gubun,'c', title))) tue_c,
         max(decode(to_date(ymd,'yyyymmdd'),wed, decode(gubun,'c', title))) wed_c,
         max(decode(to_date(ymd,'yyyymmdd'),thu, decode(gubun,'c', title))) thu_c,
         max(decode(to_date(ymd,'yyyymmdd'),fri, decode(gubun,'c', title))) fri_c,
         max(decode(to_date(ymd,'yyyymmdd'),sat, decode(gubun,'c', title))) sat_c
   from cal a left outer join tbl b on a.sun = b.ymd or a.mon = b.ymd or a.tue = b.ymd or a.wed = b.ymd or a.thu = b.ymd or a.fri = b.ymd or a.sat=b.ymd
   group by sun 
    order by a.sun
 
일자와 title 필드 합쳐야 하면  || 로 연결하세요..
1님이 2011-08-10 17:29에 작성한 댓글입니다. Edit

정말 감사드립니다. ^^ 이렇게 하면 될거 같아요

 

박수길(sookill)님이 2011-08-10 17:48에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
38772두개의 문자열 비교하여, 위치별 틀린 갯수 구하기 [3]
dol
2011-08-11
5174
38771wm_concat 의 정렬 문의좀 드릴게요... [1]
박수길
2011-08-11
12396
38769정렬(order by) 문의 [1]
채종식
2011-08-10
3484
38768캘린터 형태의 예약일정을 표시하려고 하는대 좀 도와주세요... [2]
박수길
2011-08-10
4949
38766테이블스페이스 삭제가 안되네요 [1]
백상옥
2011-08-10
3200
38765US7ASCII와 KO16KSC5601을 설정을 바꾸면 한글이 깨지지않는
초핸섬
2011-08-10
3486
38764database 오픈이 안됩니다.
한희성
2011-08-09
3236
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다