【发布时间】:2014-10-05 21:02:08
【问题描述】:
我有下表。
test_type | brand | model | band | firmware_version | avg_throughput
-----------+---------+--------+------+-----------------+----------------
1client | Linksys | N600 | 5ghz | 1 | 66.94
1client | Linksys | N600 | 5ghz | 2 | 94.98
1client | Linksys | N600 | 5ghz | 4 | 132.40
1client | Linksys | EA6500 | 5ghz | 1 | 216.46
1client | Linksys | EA6500 | 5ghz | 2 | 176.79
1client | Linksys | EA6500 | 5ghz | 4 | 191.44
我想从每个model 中选出firmware_version 最低的avg_throughput。
当我执行SELECT test_type, model, min(firmware_version) FORM temp_table GROUP BY test_type, model 时,我得到了我想要的,但是一旦我添加了avg_throughput 列,它还需要我将它添加到 GROUP BY 子句中,这样当我只需要 @ 时,它就会返回所有行987654327@ 对于每个 model 类型的最低 firmware_version。
【问题讨论】:
标签: sql postgresql greatest-n-per-group