select field1, cnt from
(select field1,count(*) cnt,
max((select max(sn) from test b where a.field1 = b.field1)) sn
from test a
group by field1
) order by sn
(select field1,count(*) cnt,
max((select max(sn) from test b where a.field1 = b.field1)) sn
from test a
group by field1
) order by sn
(select field1,count(*) cnt,
max((select max(sn) from test b where a.field1 = b.field1)) sn
from test a
group by field1
) order by sn
bb 1
cc 2
aa 2在原表中,aa的sn有两个值6,2 如何排? 不好直接这么做的. select tb.field1,count(tb.field2) from tb group by tb.field1 order by 2;