形如这样的表
user_nm seq quantity
aa 1 10
aa 2 15
bb 1 2
bb 2 8
cc 4 9
dd 2 3
如何得到每个seq最小的数据,就是结果为
user_nm seq quantity
aa 1 10
bb 1 2
cc 4 9
dd 2 3刚才问错了,呵呵。
user_nm seq quantity
aa 1 10
aa 2 15
bb 1 2
bb 2 8
cc 4 9
dd 2 3
如何得到每个seq最小的数据,就是结果为
user_nm seq quantity
aa 1 10
bb 1 2
cc 4 9
dd 2 3刚才问错了,呵呵。
where rn = 1; 或者 select user_nm,seq,quantity from table a where not exists (select 1 from table b where b.user_nm = a.user_nm and b.seq < a.seq);
select t.* from tb t where not exists(select 1 from tb where user_nm = t.user_nm and seq < t.seq)
user_nm order by seq) rn from tt) where rn=1;