select *
from t aa
where d=(select min(d) from t where a=aa.a)
from t aa
where d=(select min(d) from t where a=aa.a)
解决方案 »
- 如何让输出关联表的相关内容?
- 多个表查询,这个查询该怎么写
- 急呀,XDJM!请问如何把.XML文件转换成SQL SERVER 数据表中?
- SQL语句的小问题!请教~~~
- 高手帮忙!!!!
- 300分求购SQL,各位帮帮忙
- Reporting Services用表达式取值的问题
- sql查询
- 对这一串数(0000521438、00122a01、0000521437、0000012203、00005e689),怎么去比较大小???是指在SQL Server中?
- 执行存储过程报错
- sqlsever的全文检索,可以对硬盘某个目录下的所有文本文件建立索引,并进行全文检索吗?
- 关于int类型值的第一个字符是0的问题!!!!
where a.a=b.aand a.d=b.d
order by a.a
(select a,min(id) from yourtablename where a in (select a from yourtablenam group by a)
group by a) b
where a.a1=b.a and a.id=b.idalter table yourtablename drop id
(select a,min(id) from yourtablename where a in (select a from yourtablenam group by a)
group by a) b
where a.a1=b.a and a.id=b.idalter table yourtablename drop id
from #t
where id in (select min(id) from #t group by a)
order by a
from t1 a
where d in (select top 1 d from t1 b where a.a=b.a order by d asc)
from t1 a
where d in (select top 1 d from t1 b where a.a=b.a order by d asc)
select min(d) d,a into #a from t1 group by a order by d
go
select * from t1,#a
where t1.a=#a.a
order by t1.a
declare aa_cursor cursor for
select distinct a from tl
open aa_cursor
fetch next from aa_cursor into @a
while @@fetch_status=0
begin
insert into #aa2 select top 1 a,b,c,d from tl where a=@a group by a,b,c,d order by dfetch next from aa_cursor into @cityend
select * from #aa2
close aa_cursor
DEALLOCATE aa_cursor
declare @a varchar(3)
where not exists (select 1 from T1 b where b.a<a.a)
declare cur cursor for select distinct a from t1
open cur fetch next from cur into @aa while @@fetch_status=0
begin
select top 1 * from t1 where a=@aa
fetch next from cur into @aa
end
deallocate cur