在GROUP BY中使用时间戳函数 [英] Using a timestamp function in a GROUP BY
本文介绍了在GROUP BY中使用时间戳函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理大量的交易数据集,并希望按月分组客户个人交易的数量。我无法在 GROUP BY
中使用时间戳功能,并返回以下错误:
I'm working with a large transaction data set and would like to group a count of individual customer transactions by month. I am unable to use the timestamp function in the GROUP BY
and return the following error:
BAD_QUERY(GROUP BY中的表达式STRFTIME_UTC_USEC([DATESTART],'%b')无效)
BAD_QUERY (expression STRFTIME_UTC_USEC([DATESTART], '%b') in GROUP BY is invalid)
解决方法来实现这一点,或者我应该建立一个日历表(这可能是最简单的选择)?
Is there a simple workaround to achieve this or should I build a calendar table (which may be the simplest option)?
推荐答案
您必须使用别名:
You have to use an alias:
SELECT STRFTIME_UTC_USEC(DATESTART, '%b') as month, COUNT(TRANSACTION)
FROM datasetId.tableId
GROUP BY month
这篇关于在GROUP BY中使用时间戳函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文