sql语句查询筛选重复值问题
时间:2011-12-05
来源:互联网
表中有记录Name Price Time Describ 全部相同,只Id不同,
想筛选出其中一条记录,无论是哪一条,只要查询结果不重复就行
作者: Fs_2011 发布时间: 2011-12-05
select * from P t where not exists(select 1 from P where Name=t.Name and Price=t.Price and [Time]=t.[Time] and Describ=t.Describ and id<t.Describ )
作者: ssp2009 发布时间: 2011-12-05
select * from p t where id=(select max(id) from p where Name=t.Name and Price=t.Price and [Time]=t.[Time] and Describ=t.Describ)
作者: fredrickhu 发布时间: 2011-12-05
--方法一: select * from tb a where id=(select max(id) from tb where Name=a.Name and price=a.price and Time=a.time and Describ=a.Describ) --方法二 select * fromt b a where not exists(select 1 from tb where Name=a.Name and price=a.price and Time=a.time and Describ=a.Describ and id>a.id)
作者: pengxuan 发布时间: 2011-12-05
作者: Fs_2011 发布时间: 2011-12-05
select distinct Name, Price, Time, Describ from P
作者: qianjin036a 发布时间: 2011-12-05
select * from (select px=row_number()over(partition by Name ,Price ,Time ,Describ order by getdate()),* from tb)t where px=1
作者: fredrickhu 发布时间: 2011-12-05
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28