我的查詢作業正常,并將輸出月份為“2021-06-01 00:00:00 UTC” 如何更改此查詢以將月份輸出為字串值,例如“JAN”?
SELECT
COUNT(distinct ride_id) as total_rides,
rideable_type,
member_type,
TIMESTAMP_TRUNC(started_at, month) AS month,
FROM `data.table`
GROUP BY rideable_type,
member_type,
month;
uj5u.com熱心網友回復:
UPPER(MONTHNAME("2021-06-01 00:00:00 UTC"))
--will give JUNE
所以你需要包裝你得到的價值 UPPER(MONTHNAME(TIMESTAMP_TRUNC(started_at, month)))
uj5u.com熱心網友回復:
下面使用
format_timestamp('%Y-%b', started_at)
例子:
select format_timestamp('%Y-%b', current_timestamp())
產出

如果你只需要一個月 - 使用
format_timestamp('%b', started_at)
帶輸出

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/338946.html
標籤:sql 细绳 谷歌-bigquery 时间戳
上一篇:查找產品客戶一起購買但不重復的列
下一篇:Presto-插入缺失的時間戳
