select distinct dingdan From orders where niming=0想要排重复的是dingdan字段,以上语句可以排除重复,但得不到其它字段数据
select distinct(dingdan),actionid From orders where niming=0
这样子能得到其它字段数据,但无法排除重复的dingdan字段,请指点。
select distinct(dingdan),actionid From orders where niming=0
这样子能得到其它字段数据,但无法排除重复的dingdan字段,请指点。
解决方案 »
- sql server 2005数据库置疑修复
- 请教如何修改declare @strSQL nvarchar(4000)参数类型和长度让它正常运行,长度在1w以上。。
- 在SQL怎样定义数组?
- 江湖再求救急,求一sql语句。。。。
- SQL Server中由于登陆失败而无法启动服务的问题?
- 这样的算法该如何写?
- 解决一个问题!
- 这DataGrid控件怎么用,它默认两列,如何增加一列,应为我的数据表不纸两列
- "select * from abc_de"这样的语句中如何使“_”可使用?(AOD+ACCESS+ASP中使用)
- 数据库题目,请帮忙,有点偏
- 刚下载了sqlserver2000的SP3A,可是无法安装。请大家帮忙。
- 建临时表插入一个序号字段时时÷排序问题
insert into @t select 1,'zhang'
insert into @t select 2,'zhang'
insert into @t select 3,'li'
insert into @t select 4,'li'
insert into @t select 5,'zhou'
insert into @t select 6,'zhou'
insert into @t select 7,'zhou'
insert into @t select 8,'ding'select * from @t a where not exists(select 1 from @t b where b.id<a.id and b.name=a.name)
--方法一
select * from @t where id in(select min(id) from @t group by name)
--方法二
select * from @t where id not in(select max(id) from @t group by name)
--方法三--结果
/*
ID Name
1 zhang
3 li
5 zhou
8 ding
*/
From orders a
where niming=0
and exists(select top 1 * from orders where dingdan=a.dingdan)
From orders a
where niming=0
and exists(select 1 from orders where dingdan=a.dingdan)
into #Tmp2
from #Tmp
group by dingdanselect * from #Tmp where autoID in(select autoID from #tmp2)