---存储过程:分页,获得第@endrecord-@num+1条到第@endrecord条记录的研报信息 IF exists (select * from SysObjects where name='sp_reportpagelist' and type='p') drop procedure sp_reportpagelist go CREATE PROCEDURE sp_reportpagelist @stockcode nvarchar(20), @num int, --条数 @endrecord int --从0到该页最后一条记录的总记录数 as begin select top (@num) * from ( SELECT top (@endrecord) T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName, CASE WHEN T1.Grade=0 THEN '不评级' WHEN T1.Grade=1 THEN '买入' WHEN T1.Grade=2 THEN '增持' WHEN T1.Grade=3 THEN '减持' WHEN T1.Grade=4 THEN '卖出' WHEN T1.Grade=5 THEN '中性' END AS Grade, CASE WHEN T1.GradeUpdate=0 THEN '不评级' WHEN T1.GradeUpdate=1 THEN '首次' WHEN T1.GradeUpdate=2 THEN '调高' WHEN T1.GradeUpdate=3 THEN '维持' WHEN T1.GradeUpdate=4 THEN '调低' END AS GradeUpdate, T1.TargetPrice,T2.ReportDate FROM (select ReportID,StockCode,Grade,GradeUpdate,TargetPrice from StockReview where stockcode='000002' or stockname='000002') T1 left join Report T2 on T1.ReportID = T2.ReportID left join Company T3 on T2.CompanyID = T3.SourceID order by T2.ReportDate desc ) TT order by TT.ReportDate end GO