如果我有記錄:幫助具有鮮明行和數據排序
Row Date, LocationID, Account 1 Jan 1, 2008 1 1000 2 Jan 2, 2008 1 1000 3 Jan 3, 2008 2 1001 4 Jan 3, 2008 1 1001 5 Jan 3, 2008 3 1001 6 Jan 4, 2008 3 1002
我需要得到其中行具有最新的每個不同的locationid
日期行(date
,locatinid
,account
):
4 Jan 3, 2008 1 1001 3 Jan 3, 2008 2 1001 6 Jan 4, 2008 3 1002
謝謝,像一個魅力工作。我實際上爲表添加了一個公用表表達式,因爲where子句與我的場景非常相關,我想避免在外部select和內部select中寫出兩次。 – Jeremy 2008-11-20 00:27:08