最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

I keep getting Syntax error messages using SQL on BigQuery - Stack Overflow

programmeradmin2浏览0评论

I am a student taking an online course in data analytics. I'm learning SQL and it is my first time doing any type of coding. Recently, I've been encountering a problem where after following the instructions to the 't' I get error messages that look like this: Syntax error: Expected end of input but got "(" at [3:8]

What I've done is to let my computer sleep on it and then the following day I delete all my work and start over again. Sometimes this works. I've even reached out to the course's AI coach which could only take me so far.

Here is the SQL query:

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

I am a student taking an online course in data analytics. I'm learning SQL and it is my first time doing any type of coding. Recently, I've been encountering a problem where after following the instructions to the 't' I get error messages that look like this: Syntax error: Expected end of input but got "(" at [3:8]

What I've done is to let my computer sleep on it and then the following day I delete all my work and start over again. Sometimes this works. I've even reached out to the course's AI coach which could only take me so far.

Here is the SQL query:

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
Share Improve this question edited Nov 16, 2024 at 15:17 Thorsten Kettner 95.7k8 gold badges56 silver badges79 bronze badges asked Nov 16, 2024 at 14:45 Motlalepula MmesiMotlalepula Mmesi 1 1
  • 1 I am not familiar with Google BigQuery. In standard SQL double quotes delimit names, so a DBMS would look for a column named " to ". Backticks are not standard compliant delimiters. Do they work in BigQuery? I see that the choice of the name bigquery-public-data makes delimiters probably necessary, because of the minus sign that is not to be interpreted to mean minus. But wouldn't you then use them around the name itself: FROM `bigquery-public-data`.new_york.citibike_trips? – Thorsten Kettner Commented Nov 16, 2024 at 15:08
Add a comment  | 

1 Answer 1

Reset to default -1
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;
发布评论

评论列表(0)

  1. 暂无评论