Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Spring
- Eclipse
- window
- SPC
- mapreduce
- table
- NPM
- react
- es6
- Android
- JavaScript
- vaadin
- SQL
- Kotlin
- 보조정렬
- 공정능력
- mybatis
- hadoop
- IntelliJ
- Java
- SSL
- tomcat
- Sqoop
- Express
- MSSQL
- Python
- plugin
- GIT
- xPlatform
- R
Archives
- Today
- Total
DBILITY
현재시간기준 (3)교대일자,교대구분 구하기 본문
반응형
- 교대일자,교대구분
SELECT CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '235959' THEN TO_CHAR(SYSDATE,'YYYYMMDD') ELSE TO_CHAR(SYSDATE-NUMTODSINTERVAL('1','DAY'),'YYYYMMDD') END AS WDATE, CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '150000' THEN '1' WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '150001' AND '230000' THEN '2' ELSE '3' END AS WSHIFT FROM DUAL
- 교대일자,교대구분의 업무시간구간
SELECT (CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '235959' THEN TO_CHAR(SYSDATE,'YYYYMMDD') ELSE TO_CHAR(SYSDATE-NUMTODSINTERVAL('1','DAY'),'YYYYMMDD') END)|| (CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '150000' THEN '070001' WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '150001' AND '230000' THEN '150001' ELSE '230001' END) AS SDT, (CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '230001' AND '235959' THEN TO_CHAR(SYSDATE+NUMTODSINTERVAL('1','DAY'),'YYYYMMDD') ELSE TO_CHAR(SYSDATE,'YYYYMMDD') END)|| (CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '150000' THEN '150000' WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '150001' AND '230000' THEN '230000' ELSE '070000' END) AS EDT FROM DUAL
- 현재 교대일자,교대구분의 근무시간이 포함된 조회일시 구간을 입력 받았을때 조회시점까지만 조회
WITH T( WDATE,WSHIFT,WRKDATETIME ) AS ( SELECT '20161005','1','20161005070001' FROM DUAL UNION ALL SELECT '20161005','3','20161005230001' FROM DUAL UNION ALL SELECT '20161004','3','20161005065959' FROM DUAL UNION ALL SELECT '20161005','3','20161006000001' FROM DUAL UNION ALL SELECT '20161005','2','20161005150001' FROM DUAL UNION ALL SELECT '20161005','2','20161005225959' FROM DUAL UNION ALL SELECT '20161006','1','20161006080001' FROM DUAL ) SELECT * FROM T WHERE WDATE= (CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '235959' THEN TO_CHAR(SYSDATE,'YYYYMMDD') ELSE TO_CHAR(SYSDATE-NUMTODSINTERVAL('1','DAY'),'YYYYMMDD') END) AND WSHIFT= (CASE WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '070001' AND '150000' THEN '1' WHEN TO_CHAR(SYSDATE,'HH24MISS') BETWEEN '150001' AND '230000' THEN '2' ELSE '3' END) AND WRKDATETIME <= (CASE WHEN TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') BETWEEN :searchFromDate||:searchFromTime AND :searchToDate||:searchToTime THEN TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') ELSE '00000000000000' END)
반응형
'database > sql' 카테고리의 다른 글
oracle 점이력 선분이력으로 만들기 (0) | 2016.10.10 |
---|---|
현재시간 1초 전 구하기 (0) | 2016.10.10 |
세로를 5줄로만 표현하기 (ROW 고정) (0) | 2016.10.07 |
sql pivot row to column (행을 열로) - 구구단예제 (0) | 2016.10.05 |
oracle unpivot string comma separate to row (0) | 2016.09.07 |
Comments