如有一个表
date
200801
200802
200802
200803
200804
200805
如果不用对表进行for循环操作,如果相同的记录,只取其一条。我想查询的结果为 200801 200802 200803 200804 200805
请赐教!
date
200801
200802
200802
200803
200804
200805
如果不用对表进行for循环操作,如果相同的记录,只取其一条。我想查询的结果为 200801 200802 200803 200804 200805
请赐教!
if object_id('tempdb.dbo.#T') is not null drop table #T
create table #T (date varchar(6))
insert into #T
select '200801' union all
select '200802' union all
select '200802' union all
select '200803' union all
select '200804' union all
select '200805'select distinct date from #T
/*
200801
200802
200803
200804
200805
*/declare @s varchar(8000)
set @s=''
select @s=@s+date+' ' from (select distinct date from #t)as a
select @s
/*
200801 200802 200803 200804 200805
*/
你如果是.net里的datatable,怎么发到sql server来了...如果是datatable,应该只能用for循环吧
select distinct date from table from 表 order by date