動態統計每個日期過去30天的資料

2021-08-03 10:10:14 字數 542 閱讀 6295

今天有資料分析問我,如何動態統計過去30的數?比如0601,計算0502——0601的使用者數去重,0602,計算0503——0602內的使用者數去重,是個動態的30天使用者數

他用的spark line。具體的語法的不熟悉,但是邏輯類似,利用迴圈控制傳入的值即可

這裡利用oracle的儲存過程實現

create or replace procedure test2 is

v_date date;

begin

v_date := trunc(sysdate - 365);

while v_date<=sysdate loop

insert into t4 select count(distinct id),v_date from t3 where day_date>=trunc(v_date-30) and day_date<=v_date;

commit;

v_date := v_date+1;

end loop;

end;

這樣即可實現,每一天統計從當天到當天往前30天的資料。

JAVA 日期獲得30天前的日期

calendar calendar new gregoriancalendar system.out.println 當時日期是 calendar.gettime calendar.add calendar.date,30 system.out.println 30天前是 calendar.gett...

js 獲取當前日期的後30天

開始時間 設定為今天 thu aug 01 2019 15 00 01 gmt 0800 中國標準時間 var startdate new date console.log startdate 初始化結束時間 var enddate new date console.log enddate getd...

mysql查詢r日期周7天季度年統計表資料神器

今天select from 表名 where to days 時間欄位名 to days now 昨天select from 表名 where to days now to days 時間欄位名 1 7天select from 表名 where date sub curdate interval 7...