--try
select name,count,ass
from 表
where count=(select top 1 count from 表 where name=a.name)
and ass=(select top 1 ass from 表 where name=a.name)
group by name
select name,count,ass
from 表
where count=(select top 1 count from 表 where name=a.name)
and ass=(select top 1 ass from 表 where name=a.name)
group by name
解决方案 »
- 请问这样动态查询错在哪里
- ms sql2000 数据库自动备份问题
- SQL?????
- 关于 IN 之后接变量查不出结果的问题!高手来接分
- SQL SERVER中存储过程怎么实现累加
- 关于查询数据出现的次数的查询
- 语言代码不匹配怎么解决?
- 请教关于asp与sql server2000数据库中的存储过程连接的问题
- 我这有个SQL语句,大家能够分析一下吗?谢谢!
- 求助,在线等。用错误的bak文件恢复了数据库,能返回到恢复之前的状态吗
- 新手 问一下,能不能只用SQL SERVER2000来开发数据库应用系统啊??
- 请问smallint类型的数据占几个字节,可以表示的数的范围是多大?还有int的情况又是如何?
delete a from tb a,tb b where a.name=b.name and a.id>b.id
alter table tb drop column id
--测试环境
declare @t table(name varchar(10),count varchar(10), ass varchar(10))
insert into @t select 'qq','jj','99'
union all select 'qq','aa','88'
union all select 'qq','kk','yy'
union all select 'pp','hh','77'
union all select 'pp','gg','22'
union all select 'ww','cc','00'
union all select 'ww','33','99'
union all select 'zz','bb','99'
union all select 'zz','oo','mm'
--查询
select name,
count=(select top 1 count from @t where name=a.name),
ass=(select top 1 ass from @t where name=a.name)
from @t a
group by name
--结果
name count ass
---------- ---------- ----------
pp hh 77
qq jj 99
ww cc 00
zz bb 99(所影响的行数为 4 行)
group by name
having count = max(count)