我有一個看起來像這樣的數據:抓住每組中具有最高價值的行?
Table
Group: "A" , Color: "Blue", Count: "400"
Group: "A" , Color: "Green", Count: "3"
Group: "A" , Color: "Yellow", Count: "6"
Group: "A" , Color: "Red", Count: "1"
Group: "B" , Color: "Purple", Count: "243"
Group: "B" , Color: "Green", Count: "2"
Group: "B" , Color: "Yellow", Count: "7"
我如何可以查詢這個數據獲得各組的最流行的(通過數)的顏色。所以,結果是這樣的:
+1:一個額外的*精神* +1對字段名稱註釋。 – MatBailie 2012-02-07 16:53:18
+1,'t.count'是varchar。與'sub.ct'比較時進行轉換。 – 2012-02-07 16:53:55
@aF。 - 好點子。我實際上應該在子查詢中做一個CAST,因爲寫成'40> 300' – JNK 2012-02-07 16:55:13