码迷,mamicode.com
首页 > 数据库 > 详细

sql问题

时间:2016-04-02 00:43:08      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

表中某个指标重复,去掉重复项:

select *
from #temp
where A0107
in (select A0107 from #temp 
group by A0107
having COUNT(A0107)>1
) and id not in (
   select MIN(id) from #temp
   group by A0107
having COUNT(A0107)>1
)
select * from #temp
--实现sql server 中类似于oracle中rownum的关键字,
--我想取出符合条件的第301-310条记录,又不想取出所有数据,有没有好的解决方案?
--插入数据1,2,3,4
select identity(int,1,1) as id,* into #temp from UsrA01
select * from #temp where id between 301 and 310
--1,10插入的数据1,11,21,31,跳十个
select identity(int,1,10) as id,* into #temp1 from UsrA01
select * from #temp1 where id between 301 and 310

sql问题

标签:

原文地址:http://www.cnblogs.com/beijingstruggle/p/5346733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!