티스토리 뷰
-- 2000-01-01 부터 + 9999 일까지 달력 만들기
WITH Calendar AS (
SELECT CONCAT(y, '0101') + INTERVAL tt*1000 + a*100 + b*10 + c DAY AS dt
FROM
(SELECT 0 AS tt
UNION ALL SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
) AS tt
, (SELECT 0 AS a
UNION ALL SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
) AS a
, (SELECT 0 AS b
UNION ALL SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
) AS b
, (SELECT 0 AS c
UNION ALL SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
) AS c
, (SELECT '2022' AS y) AS d
ORDER BY dt ASC
),
-- 요일 붙이기
Calendar2 AS (
SELECT
dt AS NumDate,
DAYNAME(dt) AS EngDate
FROM Calendar
)
SELECT
Numdate
FROM Calendar2
WHERE Numdate LIKE '2022%'
ORDER BY Numdate ASC
'Database' 카테고리의 다른 글
[MSSQL]DB연결(여러개) (0) | 2022.09.13 |
---|---|
[MYSQL]그룹을 연속 된 날짜로 출력 (0) | 2022.07.04 |
[MYSQL]월별 영업일(일정테이블) (0) | 2022.04.26 |
[DB]Centos 7 MariaDB 설치 및 실행 (0) | 2022.02.21 |
[MYSQL]연간 달력 (0) | 2021.06.03 |
- Total
- Today
- Yesterday
- 백업
- Windows
- 오라클
- sql
- user
- tomcat
- Toad
- 리눅스
- eclipse
- 데이터
- IP
- java
- Shell
- 윈도우
- 테이블
- 파일
- mssql
- 자동차
- 설정
- DB
- 서버
- MySQL
- DATABASE
- apache
- select
- Oracle
- table
- Linux
- delete
- server
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |