PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 19, 2022

[FIXED] How do I incorporate FLOAT in my query when calculating the average of a set of values when my result could be a FLOAT and not INTEGER to avoid error

 July 19, 2022     average, database, google-bigquery, integer, sql     No comments   

Issue

I am trying to determine the average of a set of values from a table but I am getting an error.

I entered the query below to determine the average riderships from 2013 - 2016 but got this error - No matching signature for operator / for argument types: STRUCT<INT64, INT64>, INT64. Supported signatures: FLOAT.

SELECT
station_name,
ridership_2013,
ridership_2014,
ridership_2015,
ridership_2016,
(ridership_2013 + ridership_2014 + ridership_2015, ridership_2016) / 4 AS Average_ridership

FROM bigquery-public-data.new_york_subway.subway_ridership_2013_present;

Solution

You simply has a typo! try below

SELECT
station_name,
ridership_2013,
ridership_2014,
ridership_2015,
ridership_2016,
(ridership_2013 + ridership_2014 + ridership_2015 + ridership_2016) / 4 AS Average_ridership
FROM bigquery-public-data.new_york_subway.subway_ridership_2013_present;    

as you can see - the typowas a comma instead of plus sign in ridership_2015, ridership_2016



Answered By - Mikhail Berlyant
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing