【发布时间】:2023-01-22 23:41:26
【问题描述】:
我有一个日期需要在 SQL Presto 中汇总为季度/年度格式。请帮忙。谢谢!
【问题讨论】:
我有一个日期需要在 SQL Presto 中汇总为季度/年度格式。请帮忙。谢谢!
【问题讨论】:
Documentation 是你的朋友 - 使用对应单位的date_trunc,或extraction functions(year,quarter):
select date_trunc('quarter', now())
, date_trunc('year', now())
, quarter(now())
, year(now())
示例输出:
| _col0 | _col1 | _col2 | _col3 |
|---|---|---|---|
| 2022-07-01 00:00:00.000 UTC | 2022-01-01 00:00:00.000 UTC | 3 | 2022 |
【讨论】: