1

week日期的函数

 

如下是 hive的函数

 

select dayofweek ('2022-02-27') ; --dayofweek展示的是周几 共计 7个值 , 6代表周五


=1

select weekofyear('2022-12-22') ;
--51

 

 

 

如下为mysql 的语句 :


SELECT
WEEK(purchase_date) - WEEK('2023-11-01') + 1 week_of_month, --用hive替换的话用weekofyear purchase_date, SUM(amount_spend) total_amount FROM Purchases p WHERE SUBSTRING(purchase_date,1,7)= '2023-11' AND DAYOFWEEK(purchase_date) = 6 -- hive 也用dayofweek GROUP BY purchase_date ORDER BY week_of_month ASC ; 作者:没上岸就继续刷呗 链接:https://leetcode.cn/problems/friday-purchases-i/solutions/2785252/jian-dan-si-lu-by-eager-mooreli2-v4ce/ 来源:力扣(LeetCode) 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

posted @ 2024-08-14 17:29  萌哥-爱学习  阅读(1)  评论(0编辑  收藏  举报