我正在尝试从 databricks sql 中的日期获取 week_of_the_month
这是我的 SQL:
with date as (
select EXTRACT(DAY FROM '2017-01-01') as day
)
select case
when day < 8 then '1'
when day < 15 then '2'
when day < 22 then '3'
else '4'
end as week_of_month
上面的 sql 在某些边缘情况下会失败。例如2010-03-31
,那么week_of_month = 5
如何在 databricks SQL 中找到 week_of_month?