怎么这么难呢???? sqlserver2005 select min(id),data1,data2 from t group by data1,data2这样行不? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 declare @t table(ID int,data1 int ,data2 char(1))insert @t select 1,1,'a' insert @t select 2,2,'b' insert @t select 3,2,'b' insert @t select 4,3,'c' insert @t select 5,3,'c' insert @t select 6,4,'d'select *from @t a where not exists (select 1 from @t where data1 = a.data1 and data2 = a.data2 and id <a.id)/*ID data1 data2 ----------- ----------- ----- 1 1 a2 2 b4 3 c6 4 d*/ declare @t table(ID int,data1 int ,data2 char(1))insert @t select 1,1,'a' insert @t select 2,2,'b' insert @t select 3,2,'b' insert @t select 4,3,'c' insert @t select 5,3,'c' insert @t select 6,4,'d'select min(id) id,data1,data2 from @t group by data1,data2 如何查询销售额占总销售前80%的列表 SQL SERVER 2005 创建存储过程或函数的问题 那些复杂的sql语句哪学的? 创建维护计划中的T-SQL时调用了xp_cmdshell的小问题 sql语句问题 在SQl2000中,如何让系统自动建立表结构(100)(在线等待) Microsoft SQL Server 2005安装出错,请各位帮忙解决,非常感谢! 连表删除 sql语句疑问 有关导入 导出的问题?在线等待 在进行开发过程中发现 触发器的所有功能都能在存储过程中实现 想问一下高手如下?? 安装制作的难题 求两张表查询的SQL语句
insert @t select 1,1,'a'
insert @t select 2,2,'b'
insert @t select 3,2,'b'
insert @t select 4,3,'c'
insert @t select 5,3,'c'
insert @t select 6,4,'d'select *
from @t a
where not exists (select 1 from @t where data1 = a.data1 and data2 = a.data2 and id <a.id)/*ID data1 data2
----------- ----------- -----
1 1 a
2 2 b
4 3 c
6 4 d*/
insert @t select 1,1,'a'
insert @t select 2,2,'b'
insert @t select 3,2,'b'
insert @t select 4,3,'c'
insert @t select 5,3,'c'
insert @t select 6,4,'d'
select min(id) id,data1,data2 from @t group by data1,data2