0
我有两张医疗数据表,我希望找到每张表格中常见的医院,并在各自的表格中使用与每家医院相关的两个字段。但请记住,它们有两个不同的表格。如何使用Google BigQuery SQL交叉引用两个大数据表?
这是我到目前为止,但总是回来没有结果。
SELECT
Spending/Rating AS Ratio,
Provider_ID_Info AS ID
FROM (
SELECT
Period,
Provider_ID_Spend,
Avg_Spending_Per_Episode_Hospital as Spending,
Provider_ID_Info,
Hospital_overall_rating as Rating
FROM
[OmniHealth.HospitalSpending],
[OmniHealth.HospitalGeneralInfo]
WHERE
Provider_ID_Info = Provider_ID_Spend
GROUP BY
Rating,
Spending,
Provider_ID_Spend,
Avg_Spending_Per_Episode_Hospital,
Provider_ID_Info,
Hospital_overall_rating,
Period
)
GROUP BY
Ratio,
ID,
Spending,
Rating
ORDER BY
Ratio
非常感谢!出于某种原因,我一直在我的“比例”字段中为空。但是,如果我用他们所指的特定字段替换“支出”和“评分”,我会得到这样的错误:“无法识别的名称:Avg_Spending_Per_Episode_Hospital [2:3]” –
“,您不应该替换字段名称,或者如果您想要 - 在这种情况下,您需要删除各自的别名并使用原始字段。所以至少现在我们用JOIN的错误语法解决了你的问题。为了进一步解决NULL - 你应该为这两个表格提供简化的数据示例,以便我们能够解决这个问题。合理? –
另请参阅[如何提问](http://stackoverflow.com/help/how-to-ask)和[最小,完整和可验证示例](http://stackoverflow.com/help/mcve) –