2013-11-27 25 views
0

選擇最大帳戶我喜歡約會:在一個月內與SQL

date|account|location_code 

我想要的是抓住每結算日最高位置與SQL語句。

11/11/2013|456456|91458 

回答

2

看起來你只是尋找一個GROUP BY

SELECT date, account, MAX(location_code) FROM table 
GROUP BY date, account 

這將返回最大location_code在每一天的每個帳戶。

+0

但是這隻會返回最大基於數字,但我需要最大位置代碼使用,如果我使用該示例它將返回最大基於數字即5000,5001和eventhouhg第一個位置使用100次其他使用只有2時間仍然會返回5001 – hi4ppl