日期:2014-05-18 浏览次数:20554 次
SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY app.Processingtime DESC) AS pos, app.userid,app.Id AS aid,app.Type,app.Loanamount,app.LoanUse,app.Locationarea, app.Collateralname,app.LoanTitle,app.LoanContent,app.Addtime,app.Processingtime,app.IsIndex,app.LoanCity, app.CountHit,app.CountLeave,pro.ProvinceName,city.CityName,men.Id AS mid,men.TrueName,men.HeadInphoto,men.Headphoto FROM dbo.tb_Apply AS app INNER JOIN RegionalismProvinceCode pro ON app.Locationarea=pro.ProvinceID INNER JOIN RegionalismCityCode city ON city.CityID=app.LoanCity INNER JOIN dbo.tb_Menbermation AS men ON app.Userid=men.Userid UNION SELECT ROW_NUMBER() OVER (ORDER BY app.Processingtime DESC) AS pos, app.userid,app.Id AS aid,app.Type,app.Loanamount,app.LoanUse,app.Locationarea, app.Collateralname,app.LoanTitle,app.LoanContent,app.Addtime,app.Processingtime,app.IsIndex,app.LoanCity,app.CountHit,app.CountLeave, pro.ProvinceName,city.CityName,ent.Id AS eid,ent.TrueName,ent.HeadInphoto,ent.Headphoto FROM dbo.tb_Apply AS app INNER JOIN RegionalismProvinceCode pro ON app.Locationarea=pro.ProvinceID INNER JOIN RegionalismCityCode city ON city.CityID=app.LoanCity INNER JOIN dbo.tb_MenberEnterprise AS ent ON app.Userid=ent.Userid) AS sp
;WITH t AS ( SELECT ROW_NUMBER() OVER ( ORDER BY Processingtime DESC ) AS row_id, * FROM ( SELECT app.userid, app.Id AS aid, app.Type, app.Loanamount, app.LoanUse, app.Locationarea, app.Collateralname, app.LoanTitle, app.LoanContent, app.Addtime, app.Processingtime, app.IsIndex, app.LoanCity, app.CountHit, app.CountLeave, pro.ProvinceName, city.CityName, men.Id AS mid, men.TrueName, men.HeadInphoto, men.Headphoto FROM dbo.tb_Apply AS app INNER JOIN RegionalismProvinceCode pro ON app.Locationarea = pro.ProvinceID INNER JOIN RegionalismCityCode city ON city.CityID = app.LoanCity INNER JOIN dbo.tb_Menbermation AS men ON app.Userid = men.Userid UNION SELECT app.userid, app.Id AS aid, app.Type, app.Loanamount, app.LoanUse, app.Locationarea, app.Collateralname, app.LoanTitle, app.LoanContent, app.Addtime, app.Processingtime, app.IsIndex, app.LoanCity, app.CountHit, app.CountLeave, pro.ProvinceName, city.CityName, ent.Id AS eid, ent.TrueName, ent.HeadInphoto, ent.Headphoto FROM dbo.tb_Apply AS app INNER JOIN RegionalismProvinceCode pro ON app.Locationarea = pro.ProvinceID INNER JOIN RegionalismCityCode city ON city.CityID = app.LoanCity INNER JOIN dbo.tb_MenberEnterprise AS ent ON app.Userid = ent.Userid ) AS sp ) SELECT * FROM t WHERE row_id BETWEEN 1 AND 10