티스토리 뷰
# YYYY-MM-DD
select * from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where selected_date between '2024-01-01' and '2024-12-31'
# YYYY-MM
select DISTINCT DATE_FORMAT(selected_date, '%Y-%m') AS selected_date from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where selected_date between '2024-01-01' and '2024-12-31'
'Database' 카테고리의 다른 글
[MYSQL]몇 년치 날짜데이터 테이블 만들기 (0) | 2024.05.29 |
---|---|
[MSSQL]매월 3째주 금요일 구하기(쿼리검증필요/주차관련) (0) | 2024.04.09 |
Elastic Search (0) | 2024.02.15 |
[mariadb] WITH 재귀쿼리 계층구조(조직도) (0) | 2024.02.15 |
[MYSQL]초단위 -> 일시분초 (0) | 2023.04.14 |
- Total
- Today
- Yesterday
- java
- 데이터
- apache
- DB
- delete
- DATABASE
- select
- eclipse
- 설정
- mssql
- MySQL
- Toad
- Linux
- Oracle
- Windows
- server
- sql
- 서버
- 파일
- 오라클
- Shell
- IP
- 백업
- 자동차
- 윈도우
- table
- tomcat
- user
- 리눅스
- 테이블
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |