Table_01:選擇從一個表中不同的用戶和其他表的最新日期
----------------
ROW_ID | NAME
----------------
11223 | Frank
11224 | Frank
11225 | James
11226 | James
11227 | Joe
11228 | Joe
11229 | Joe
11230 | Tom
11231 | Tom
11232 | Tom
Table_02:
--------------------------------------------------
ROW_ID | NAME | EVENT_DATE | EVENT_LOCATION
--------------------------------------------------
11106 | Frank | 27/01/2017 | London
11109 | Frank | 19/01/2017 | Munich
11105 | James | 27/01/2017 | New York
11110 | James | 02/01/2017 | L.A
11101 | Joe | 27/01/2017 | Paris
11104 | Joe | 26/01/2017 | Barcelona
11107 | Joe | 31/01/2017 | Tokyo
11102 | Tom | 24/01/2017 | Prague
11103 | Tom | 03/01/2017 | Lisbon
11108 | Tom | 20/01/2017 | Dublin
我想查詢Table_01爲不同的用戶,也知道自己最最近EVENT_DATE和EVENT_LOCATION從表_02
答案:
---------------------------------------------------
NAME | NAME | EVENT_DATE | EVENT_LOCATION
---------------------------------------------------
Frank | Frank | 27/01/2017 | London
James | James | 27/01/2017 | New York
Joe | Joe | 31/01/2017 | Tokyo
Tom | Tom | 24/01/2017 | Prague
的Microsoft SQL Server 2016兼容級別:SQL Server 2005中(90)
什麼table_02和T2之間的區別? –
't2'是'table_02'的別名。 –