hive計算每個月和每週的第一天的count(*)

1、計算每個月的第一天的count(*)

select p_day as subDay,count(*) sumCount from t_app_sbd 
where p_day>=20200201 and substr(p_day,7,8)='01' group by p_day limit 10

2、計算每週的第一天的count(*)

select p_day as subDay,count(*) sumCount from t_app_sbd 
where p_day>=20200201 and pmod(datediff(to_date( date),’1900-01-08’),7)=0
 group by p_day limit 10

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章