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

SQL中分页与distinct冲突解决方案

时间:2016-05-18 12:23:10      阅读:1346      评论:0      收藏:0      [点我收藏+]

标签:

SELECT list.* FROM(SELECT ROW_NUMBER() OVER(ORDER BY salesStatus.LastTime DESC,school.SchoolID DESC) AS rownumber, school.SchoolID,school.SchoolName,school.ProvinceID,school.CityID,school.DistrictID,salesStatus.IsHave,salesStatus.IsLocked,salesStatus.IsShortProtect,
salesStatus.IsAgent,salesStatus.ExpireAllot,sExt.CreatorProtect,school.SchoolLevel,
CHARINDEX(‘3‘,SchoolLevel)  AS IsShengZhongDian,CHARINDEX(‘5‘,school.SchoolLevel) AS IsBaiQiang FROM Area_School AS school LEFT JOIN B_ProductSalesStatus AS salesStatus on salesStatus.SchoolID=school.SchoolID LEFT JOIN B_SchoolOperateAuthExt AS sExt ON school.SchoolID = sExt.SchoolID {0} {1})  AS list WHERE ROWNUMBER BETWEEN  {2} AND {3}

SQL中分页与distinct冲突解决方案

标签:

原文地址:http://www.cnblogs.com/studyjava/p/5504490.html

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