SQL中分页与distinct冲突解决方案
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}