使用fh-bigquery:weather_gsod
数据集,我希望检索特定国家所有站点的一些月度天气数据。也就是说,我想要从1929年到现在的月平均温度,月平均最高值和月平均分。
这是我写的,从一个表中检索我所需要的东西,2015年。我得到的数据似乎是正确的:
SELECT stn, FIRST(name) AS station_name, mo, (AVG(temp)-32)*0.5556 AS temp, (AVG(max)-32)*0.5556 AS max, (AVG(min)-32)*0.5556 AS min
FROM [fh-bigquery:weather_gsod.gsod2015] gsod
JOIN [fh-bigquery:weather_gsod.stations2] stations
ON gsod.wban=stations.wban AND gsod.stn=stations.usaf
WHERE country='SA'
GROUP BY stn, mo
ORDER BY mo
假设这个查询确实检索了我所需要的信息,我如何重写它,以便包含整个范围(1929年至2016年)?
发布于 2016-05-27 04:49:15
为此,您应该使用表通配符函数,如下所示
SELECT
stn,
FIRST(name) AS station_name,
mo,
(AVG(temp)-32)*0.5556 AS temp,
(AVG(max)-32)*0.5556 AS max,
(AVG(min)-32)*0.5556 AS min
FROM (
SELECT * FROM
(TABLE_QUERY([fh-bigquery:weather_gsod], 'table_id CONTAINS "gsod"'))
) gsod
JOIN [fh-bigquery:weather_gsod.stations2] stations
ON gsod.wban=stations.wban AND gsod.stn=stations.usaf
WHERE country='SA'
GROUP BY stn, mo
ORDER BY mo
https://stackoverflow.com/questions/37481635
复制相似问题