| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 478 人关注过本帖
标题:在分页查询中能不能让distinct不包含rownum
只看楼主 加入收藏
烧包谷
Rank: 2
等 级:论坛游民
威 望:2
帖 子:60
专家分:69
注 册:2010-10-11
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:3 
在分页查询中能不能让distinct不包含rownum
WITH result AS (
"SELECT b.Id as ID,b.Number as Number,b.UserName as Creater,b.BusinessTheme as Them,d.DeptName as DeptName,b.CreateTime as CreateTime,fp.UpdateTime as UpdateTime,u.staffid as Staffid,t.username as AccpetName");
,ROW_NUMBER() OVER(ORDER BY b.Id asc) AS rownum FROM BusinessApply b
 join FlowProcess fp on b.Id=fp.BizOrderId join tbl_dept d on b.UserDeptId=d.Id join tbl_user as u on u.userid = b.UserId join CooperativeAudiTasks as c on c.ProcessId=fp.Id join tbl_user as t on t.userid=c.UserId
 join FlowOperatorLog fol  on b.id=fol.BizOrderNo WHERE c.Status=0 )
SELECT TOP(@pageSize) * FROM result WHERE rownum > (@pageSize*@paeIndex)
在这一sql中,能不能用distinct。谢谢大家指点。
搜索更多相关主题的帖子: result 查询 
2012-09-17 20:59
烧包谷
Rank: 2
等 级:论坛游民
威 望:2
帖 子:60
专家分:69
注 册:2010-10-11
收藏
得分:0 
第一次贴的sql语句中错了
WITH result AS (
SELECT b.Id as ID,b.Number as Number,b.UserName as Creater,b.BusinessTheme as Them,d.DeptName as DeptName,b.CreateTime as CreateTime,fp.UpdateTime as UpdateTime,u.staffid as Staffid,t.username as AccpetName");
 ,ROW_NUMBER() OVER(ORDER BY b.Id asc) AS rownum FROM BusinessApply b
join FlowProcess fp on b.Id=fp.BizOrderId join tbl_dept d on b.UserDeptId=d.Id join tbl_user as u on u.userid = b.UserId join CooperativeAudiTasks as c on c.ProcessId=fp.Id join tbl_user as t on t.userid=c.UserId
join FlowOperatorLog fol  on b.id=fol.BizOrderNo WHERE c.Status=0 )
 SELECT TOP(@pageSize) * FROM result WHERE rownum > (@pageSize*@paeIndex)
 在这一sql中,能不能用distinct。谢谢大家指点。
2012-09-17 21:00
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:20 
为什么不用存储过程呢?

59ita点com(我就爱TA)
2012-09-18 13:16
烧包谷
Rank: 2
等 级:论坛游民
威 望:2
帖 子:60
专家分:69
注 册:2010-10-11
收藏
得分:0 
额,我储存过程写的很差!
2012-09-30 07:05
快速回复:在分页查询中能不能让distinct不包含rownum
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042901 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved