SQL
自己結合
同じnum1の行のうち、num2の数字がもっとも小さい行を取り出す。
# select * from t1; id | num1 | num2 ----+------+------ 1 | 10 | 100 2 | 10 | 110 3 | 20 | 200 4 | 20 | 190 # select a.id, a.num1, a.num2 from t1 as a , t1 as b where a.num1 = b.num1 and a.num2 >= b.num2 group by a.id, a.num1, a.num2 having count(*) = 1; id | num1 | num2 ----+------+------ 1 | 10 | 100 4 | 20 | 190