MySQL 獲取時間軸,跪求優化

2021-08-26 17:04:55 字數 1498 閱讀 1793

在搭建資料倉儲的過程中像時間,我們經常要獲取各種形式的時間軸,oracle很強大我們輕易就可以獲取,例如:

select trunc(sysdate, 'mm') + rownum - 1

from dual

connect by rownum <= to_number(to_char(last_day(sysdate), 'dd'))

mysql中我目前只能這樣做,希望達人優化下,順便提公升下我的sql 能力

select date_add(date_sub(curdate(),interval day(curdate())-1 day) ,interval a.idx day) from 

(select 0 idx

union all

select 1 idx

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

union all

select 10

union all

select 10

union all

select 11

union all

select 12

union all

select 13

union all

select 14

union all

select 15

union all

select 16

union all

select 17

union all

select 18

union all

select 19

union all

select 20

union all

select 21

union all

select 22

union all

select 23

union all

select 24

union all

select 25

union all

select 26

union all

select 27

union all

select 28

union all

select 29

union all

select 30) a where a.idx

MySQL 獲取時間軸,跪求優化

在搭建資料倉儲的過程中像時間,我們經常要獲取各種形式的時間軸,oracle很強大我們輕易就可以獲取,例如 select trunc sysdate,mm rownum 1 from dual connect by rownum to number to char last day sysdate d...

mysql 時間軸 使用MySQL計算時間軸的變化

我是mysql的新手,我需要你的幫助.我有一張包含類似資料的 robotposx robotposy robotposdir robotshortestpath 0.1 0.2 15 1456 0.2 0.3 30 1456 0.54 0.67 15 1456 0.68 0.98 22 1234 0...

MySQL 生成 時間軸

drop procedure if exists pro dim date tudou gyyx create procedure pro dim date in bdate date,in edate date begin declare var date default bdate declar...