我正在尝试在 BigQuery (标准 SQL)中编写一个非常标准的 date_trunc 查询,但它没有运行
我只在Postgres仓库(RedShift)上使用过SQL,所以我没有意识到BigQuery到目前为止使用了不同的版本...下面是我试图运行的查询:
SELECT date_trunc ('month', c.created) AS month
, COUNT (DISTINCT (c.id)) AS charges
FROM stripe.charges c
GROUP BY 1
ORDER BY 1
然后这是我收到的错误消息:
java.sql.sqlexception:[simba] [bigqueryjdbcdriver](100032)错误执行查询作业。消息:需要有效的日期零件名称,但发现C.在[1:29]
上创建。
我在BigQuery Date_trunc上阅读了大约15个不同的堆栈溢出件,但是所有这些都比我的问题更复杂...结果,我尝试过的任何事情都没有工作...
I have only ever used SQL on a postgres warehouse (Redshift), so I didn't realize that BigQuery used a different version until now... Below is the query that I'm trying to get to run:
SELECT date_trunc ('month', c.created) AS month
, COUNT (DISTINCT (c.id)) AS charges
FROM stripe.charges c
GROUP BY 1
ORDER BY 1
And then here is the error message I receive:
java.sql.SQLException: [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: A valid date part name is required but found c.created at [1:29]
I've read about 15 different stack overflow pieces on bigquery date_trunc, but all of them are for more complex problems than mine... As a result, nothing I've tried has worked...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须切换
date_trunc
参数的顺序,然后从'月份'
中删除引号:You have to switch the order of the parameters of
DATE_TRUNC
and remove the quotes from'month'
: