일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- String[]
- 폐업자에 대한 업종등의 정보내역
- mysql
- mysql trigger
- checkbox 값처리
- 2개 테이블
- eclipse hotdeploy
- 한국소프트웨어산업협회
- 주소 좌표변환
- http https
- TM128
- Oracle
- 컴퓨터 드라이버
- jquery selectbox change
- partition by
- 아이폰키보드
- ajax 동기방식처리
- extundelete
- map api v3
- multipart
- group by max
- ant path pattern
- String 배열
- remote ip
- 접속ip
- update
- KOSA
- 첫주 및 마지막주 날짜 전체 포함
- 서브쿼리
- ajax async
- Today
- Total
하은양 믿음군 효실맘 호홍홍집s
Oracle 시설예외시간을 MySql로 불러오기 Subquery 본문
Oracle :
sSql = "SELECT CALES.DATES,TO_CHAR(TO_DATE(CALES.DATES,'YYYYMMDD'),'D') DATE_WEEK,EXP_SEQ,SDATE,STIME,EDATE,ETIME,TITLE,NAME " +
"FROM ( " +
" SELECT TO_CHAR(TO_DATE('"+sFirstDate+"','YYYYMMDD') + ROWNUM - 1,'YYYYMMDD') DATES " +
" FROM ALL_OBJECTS " +
" WHERE ROWNUM <= (LAST_DAY(TO_DATE('"+sFirstDate+"','YYYYMMDD')) - TO_DATE('"+sFirstDate+"','YYYYMMDD')) +1 " +
") CALES, " +
"( " +
" SELECT DATES,EXP_SEQ,SDATE,STIME,EDATE,ETIME,TITLE,NAME " +
" FROM ( " +
" SELECT " +
" IEXP.EXP_SEQ, " +
" TO_CHAR(IEXP.SDATE,'YYYYMMDD') SDATE, TO_CHAR(IEXP.SDATE,'HH24:MI') STIME, " +
" TO_CHAR(IEXP.EDATE,'YYYYMMDD') EDATE, TO_CHAR(IEXP.EDATE,'HH24:MI') ETIME, " +
" IEXP.TITLE,ITM.NAME " +
" FROM TB_ITEMS_EXP IEXP, TB_ITEMS ITM " +
" WHERE IEXP.ITEM_ID = ITM.ITEM_ID " +
" ) TB_EXP, " +
" ( " +
" SELECT TO_CHAR(TO_DATE('"+sFirstDate+"','YYYYMMDD') + ROWNUM - 1,'YYYYMMDD') DATES " +
" FROM ALL_OBJECTS " +
" WHERE ROWNUM <= (LAST_DAY(TO_DATE('"+sFirstDate+"','YYYYMMDD')) - TO_DATE('"+sFirstDate+"','YYYYMMDD')) +1 " +
" ) CAL " +
" WHERE CAL.DATES BETWEEN TB_EXP.SDATE AND TB_EXP.EDATE " +
" ORDER BY CAL.DATES, TB_EXP.SDATE " +
") CAL_TB_EXP " +
"WHERE CALES.DATES = CAL_TB_EXP.DATES(+) " +
"ORDER BY CALES.DATES,STIME ";
MySql :
sSql = "SELECT CALES.DATES, DAYOFWEEK(STR_TO_DATE(CALES.DATES,'%Y%m%d')) DATE_WEEK, EXP_SEQ, SDATE, STIME, EDATE, ETIME, TITLE, NAME " +
"FROM ( " +
" SELECT DATE_FORMAT(TDATE,'%Y%m%d') DATES " +
" FROM TB_BIZDAY " +
" WHERE TDATE >= STR_TO_DATE('"+sFirstDate+"','%Y%m%d') AND TDATE <= LAST_DAY(STR_TO_DATE('"+sFirstDate+"','%Y%m%d')) " +
") CALES LEFT OUTER JOIN " +
"( " +
" SELECT DATES,EXP_SEQ,SDATE,STIME,EDATE,ETIME,TITLE,NAME " +
" FROM ( " +
" SELECT IEXP.EXP_SEQ, IEXP.TITLE, ITM.NAME, " +
" DATE_FORMAT(IEXP.SDATE,'%Y%m%d') SDATE, DATE_FORMAT(IEXP.SDATE,'%H%i') STIME, " +
" DATE_FORMAT(IEXP.EDATE,'%Y%m%d') EDATE, DATE_FORMAT(IEXP.EDATE,'%H%i') ETIME " +
" FROM TB_ITEMS_EXP IEXP, TB_ITEMS ITM " +
" WHERE IEXP.ITEM_ID = ITM.ITEM_ID " +
" ) TB_EXP, " +
" ( " +
" SELECT DATE_FORMAT(TDATE,'%Y%m%d') DATES " +
" FROM TB_BIZDAY " +
" WHERE TDATE >= STR_TO_DATE('"+sFirstDate+"','%Y%m%d') AND TDATE <= LAST_DAY(STR_TO_DATE('"+sFirstDate+"','%Y%m%d')) " +
" ) CAL " +
" WHERE CAL.DATES BETWEEN TB_EXP.SDATE AND TB_EXP.EDATE " +
" ORDER BY CAL.DATES, TB_EXP.SDATE " +
") CAL_TB_EXP " +
" ON CALES.DATES = CAL_TB_EXP.DATES " +
"ORDER BY CALES.DATES,STIME ";
'가벼운 배움 > MySql' 카테고리의 다른 글
여러 테이블 left outer join 처리하기 (0) | 2016.12.26 |
---|---|
Mysql trigger 사용 예제 (0) | 2016.12.23 |
Oracle 임의 키생성을 Mysql로 처리 (0) | 2016.12.21 |
2개 Table Join 해서 한 테이블의 값을 UPDATE (0) | 2016.04.07 |
Mysql union all이용한 시간단위 값가져오기 편법 ㅋㅋ (0) | 2016.02.26 |