如何解决BigQuery报错:Syntax error: Expected end of input but got "(" at [3:11]
问题根因
你遇到的语法报错是SELECT子句的多个返回字段之间遗漏了英文逗号分隔,一共漏了2处:
- 第一个字段
usertype末尾没有加英文逗号 CONCAT()定义的route字段末尾没有加英文逗号
解析器读取到第3行第11位(CONCAT的左括号位置)时,误判前面的SELECT子句已经结束,因此抛出Expected end of input but got "("错误,和你调整引号、括号位置的操作无关。
修正后的完整SQL代码
SELECT usertype, CONCAT(start_station_name,"to",end_station_name) AS route, COUNT(*) as num_trips, ROUND(AVG(cast(tripduration as int64)/60),2) AS duration FROM `bigquery-public-data.new_york.citibike_trips` GROUP BY start_station_name, end_station_name, usertype ORDER BY num_trips DESC LIMIT 10
内容的提问来源于stack exchange,提问作者Turner
相关产品推荐
相关产品推荐

