好象也不对。万一原数据是这样的。Name BNum ENumaaa 10 20aaa 20 40aaa 30 35bbb 12 22bbb 20 12出来的结果是Name BNum ENumaaa 20 40aaa 30 35bbb 20 12
select a.bnum ,a.name ,b.enum from (select max(bNum) as bNum ,Name from table group by Name) ainner join table b on a.name = b.name and a.bnum = b.bnum
[此贴子已经被作者于2006-11-14 10:40:32编辑过]
Name BNum ENumaaa 10 20aaa 20 40aaa 30 35bbb 12 22bbb 11 12bbb 13 20
要求选出以Name分组的每组中BNum最大的数据select a.* from tb a,
(select name , max(bnum) as bnum from tb group by name) b
where a.name = b.name and a.bnum = b.bnum
谢谢了,