2
我有以下兩個表:便攜式SQL與GROUP BY和加入
表1:
Id DeviceName DeviceLocation AdditionalColumn1 AdditionalColumn2
1 xyz Africa SomeColText1 SomeText1
2 abc USA SomeColText2 SomeText2
表2:
Id Name ExternalId DeviceName DeviceLocation Version
1 yyy 10 xyz Africa 1
2 bbb 11 xyz Africa 1
3 uuu 10 abc USA 2
我試圖拿出一個大號SQ
這將使我得到Table2
中的所有值,它們與Table1
連接,並從Table1(AdditionalColumn1, AdditionalColumn2)
獲取其他字段。此外,我想從Table2
中獲取最大爲Version
的元素。因此,預期的結果應該是:
Id Name ExternalId DeviceName DeviceLocation Version AdditionalColumn1
2 bbb 11 xyz Africa 1 SomeColText1
3 uuu 10 abc USA 2 SomeColText2
我有一個基本的版本設置,但是這將是一個更便攜版本,跨數據庫的作品?
什麼是Table 1和Table之間的聯繫?表2中的版本是什麼?它是什麼版本? –
我可以有一個給定的externalId的多個版本,並在版本列下進行跟蹤! – sparkr
Table1有一個組合的主鍵,它是DeviceName和DeviceLocation的組合,我在表2中使用這些信息。 – sparkr