BigQuery 中出现“无法识别的名称:m01_order_datetime_gmt0”错误

Posted

技术标签:

【中文标题】BigQuery 中出现“无法识别的名称:m01_order_datetime_gmt0”错误【英文标题】:"Unrecognized name: m01_order_datetime_gmt0" error in BigQuery 【发布时间】:2018-09-28 06:18:19 【问题描述】:

下面是我收到错误的脚本

错误:无法识别的名称:m01_order_datetime_gmt0 at [9:19]

代码

`select
case
when number_of_bookings = 1 then '1'
when number_of_bookings = 2 then '2'
when number_of_bookings = 3 then '3'
else '>3' end as number_of_bookings,
count(user_id) as number_of_users,
date_trunc(date(m01_order_datetime_gmt0), month) as Booking_month
from
(select
 user_id,
 count(distinct order_id) number_of_bookings
from analyst_all_orders
where 1=1
and d181_business_platform_code is not null
and date(m01_order_datetime_gmt0) between '2018-03-01' AND '2018-08-31'
group by 1
order by 1) as a
group by 1
order by 1`

【问题讨论】:

我无法给出确切的答案,但我会指出您在子查询中别名为aORDER BY 要么不正确,要么至少毫无意义。你应该删除它。 【参考方案1】:

试试这个:

`select
case
when number_of_bookings = 1 then '1'
when number_of_bookings = 2 then '2'
when number_of_bookings = 3 then '3'
else '>3' end as number_of_bookings,
count(user_id) as number_of_users,
date_trunc(date(m01_order_datetime_gmt0), month) as Booking_month
from
(select
 user_id,
 count(distinct order_id) number_of_bookings
 , M01_ORDER_DATETIME_GMT0
from analyst_all_orders
where 1=1
and d181_business_platform_code is not null
and date(m01_order_datetime_gmt0) between '2018-03-01' AND '2018-08-31'
group by 1
order by 1) as a
group by 1
order by 1`

(如果子查询不将列传递给周围查询,则周围查询将不知道该列)

【讨论】:

以上是关于BigQuery 中出现“无法识别的名称:m01_order_datetime_gmt0”错误的主要内容,如果未能解决你的问题,请参考以下文章

在 BigQuery 中提取字符串和第一次出现的内容之间的字符

BigQuery Left Outer 出现 OR 条件错误

如何使用 BigQuery 槽

将 Avro 文件加载到 BigQuery 失败并出现内部错误

bigquery中的GA4流量源数据不正确

BigQuery - Apache Avro 库无法解析标头并出现以下错误:数据文件无效。魔法不匹配