我有一個視圖(這是幾個表的聯合),我需要篩選出重複。該表是這樣的:我如何使用GROUP BY選擇其他列與TSQL查詢
id first last logo email entered
1 joe smith i.jpg [email protected] 2014-01-27
2 jim smith b.jpg [email protected] 2014-01-27
3 bob smith z.jpg [email protected] 2014-01-27
9 joeseph smith q.gif [email protected] 2014-01-20
我想要做這樣的事情,但我似乎無法得到一個有效的語法:
SELECT
email, MAX(entered), first, last -- such that first and last come from the same row as the MAX(entered)
FROM
my_view
GROUP BY
email
謝謝。我接受了你的答案,因爲它更詳細地解釋了原因和原因。 – Nate