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

I am a student taking an online course in data analytics. I'm learning SQL and it is my first time

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;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745656207a4638558.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信