如有a,b,c,d四列,怎么得到只有a唯一的查询.
现状:
a b c d
1 2 5 6
1 2 8 10
2 3 4 7
2 0 4 9
希望的效果:
a b c d
1 2 5 6
2 3 4 7即不管b,c,d重复,只取a不重复的第一行.怎么写???
现状:
a b c d
1 2 5 6
1 2 8 10
2 3 4 7
2 0 4 9
希望的效果:
a b c d
1 2 5 6
2 3 4 7即不管b,c,d重复,只取a不重复的第一行.怎么写???
解决方案 »
- 一个SQL分类的问题 求高手
- 这个SQL语句怎么写?关于百分比的
- 这个查询语怎么写?(查询字段值包含了某个数值的所有结果)
- 两个表的结构相同,表数据有些有相同,如何找出不相同的数据,还有不同在哪里
- 直接备份.MDF文件能不能把JOB文件也备份下来啊
- 如何将SQL2000中表的数据导入导出?
- 我第一次写存储过程,为什么查询速度好慢啊 高手给批批,重分有奖!急
- 问一个带参数的SQLSERVER存储过程如何在SQLSERVER中调试?
- 如何在sql里面把一个属性值设在一个取值域里面啊
- 关于SQL SERVER+VB奇怪问题的再次说明
- 查无重复数据的前N条记录,求高效的sql语句
- 求一sql语句,请各位高手进来帮忙.
select * from # t where id=
(select top 1 id from # where a=t.a)
drop table #,表
select * from A where id in( select distinct a from A)
(a int, b int, c int, d int)
insert into t
select 1, 2, 5, 6 union all
select 1, 2, 8, 10 union all
select 2, 3, 4, 7 union all
select 2, 0, 4, 9
select identity(int,1,1)as id,* into #t from t
Select a,b,c,d From #t A
Where Exists (Select Count(*) From #t Where id<A.id and a = A.a Having Count(*) < 1)
Order By a
a b c d
----------- ----------- ----------- -----------
1 2 5 6
2 3 4 7(2 row(s) affected)