我试图从Google的BigQuery中的多个表中进行查询。我收到了错误" Field' w.max_temperature'表格' weather.stations'中没有找到。"
这是我的SQL:
SELECT w.station_number, s.LAT, s.LON, w.year, w.month, avg(w.mean_temp) as [mean temp], max(w.max_temperature) as [max temp], min(w.min_temperature) as [min temp], avg(w.mean_visibility) as [avg visbility]
FROM [weather.stations] s, [publicdata:samples.gsod] w
WHERE w.station_number=s.USAF AND w.wban_number=s.WBAN
GROUP BY w.month, w.year, w.station_number, s.LAT, s.LON;
我试图引用" max_temperature"至[publicdata:samples.gsod],但无论出于何种原因,它都将其引用到[weather.stations]。有任何想法吗?谢谢!
答案 0 :(得分:4)
您最想要的是:
SELECT w.station_number, s.LAT, s.LON, w.year, w.month,
avg(w.mean_temp) as [mean temp], max(w.max_temperature) as [max temp],
min(w.min_temperature) as [min temp],
avg(w.mean_visibility) as [avg visbility]
FROM [weather.stations] s,
JOIN [publicdata:samples.gsod] w
ON w.station_number=s.USAF AND w.wban_number=s.WBAN
GROUP BY w.month, w.year, w.station_number, s.LAT, s.LON;