查询重复问题
时间:2011-11-23
来源:互联网
输出4条信息 有三条重复 请问怎么排查重复 重复字段 b.chrimage
麻烦给个实例 谢谢
作者: cckakaok 发布时间: 2011-11-23
作者: AcHerat 发布时间: 2011-11-23
Select TOP 4 a.detailsid,a.chrtitle,b.liveid, imgt=b.chrimage From [live] a Join [live_file] b On a.detailsid = b.liveid where jingjia=1 GROUP BY a.detailsid,a.chrtitle,b.liveid,b.chrimage order by a.detailsid desc
作者: roy_88 发布时间: 2011-11-23
--------------
其它3字段不重復?
作者: roy_88 发布时间: 2011-11-23
;with cte as( Select TOP 4 a.detailsid,a.chrtitle,b.liveid, imgt=b.chrimage From [live] a Join [live_file] b On a.detailsid = b.liveid where jingjia=1 ) select detailsid,chrtitle,liveid,imgt from cte a where not exists( select 1 from cte where imgt=a.imgt and detailsid>a.detailsid )
作者: geniuswjt 发布时间: 2011-11-23
;with cte as( Select TOP 4 a.detailsid,a.chrtitle,b.liveid, imgt=b.chrimage From [live] a Join [live_file] b On a.detailsid = b.liveid where jingjia=1 order by a.detailsid desc ) select detailsid,chrtitle,liveid,imgt from cte a where not exists( select 1 from cte where imgt=a.imgt and detailsid>a.detailsid or (detailsid=a.detailsid and liveid>a.liveid) )
SQL code
;with cte as(
Select TOP 4 a.detailsid,a.chrtitle,b.liveid, imgt=b.chrimage From [live] a Join [live_file] b On a.detailsid = b.liveid where jingjia=1
)
select detailsid,chrtitle,liveid……
作者: geniuswjt 发布时间: 2011-11-23
SQL code
Select TOP 4 a.detailsid,a.chrtitle,b.liveid, imgt=b.chrimage
From [live] a Join [live_file] b On a.detailsid = b.liveid
where jingjia=1
GROUP BY a.detailsid,a.chrtitle,b.liveid,b.ch……
楼上直接执行后 还是有重复
作者: cckakaok 发布时间: 2011-11-23
作者: cckakaok 发布时间: 2011-11-23
引用 2 楼 roy_88 的回复:
SQL code
Select TOP 4 a.detailsid,a.chrtitle,b.liveid, imgt=b.chrimage
From [live] a Join [live_file] b On a.detailsid = b.liveid
where jingjia=1
GROUP BY a.detailsid,a.chrt……
有一個一字不相同都會出來多條
把重復列用 group by ,不重復的用select max(列)
作者: roy_88 发布时间: 2011-11-24
4楼你写的什么版本的啊?
作者: geniuswjt 发布时间: 2011-11-24
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28