查询同类型文章,时间为当篇文章以前出现的10篇文章(不包含当篇文章)
alter proc QsqArticleByClassId
@artId int=null,
@artClassId varchar(500),
@rowsCount int=null
as
if @rowsCount>0
set ROWCOUNT @rowsCount
begin
declare @date datetime
select @date = ArtPassDate from QsqArticle where artId = @artId
select * from QsqArticle where artClassId=@artClassId and artId<>@artId
and ArtPassDate<=@date order by ArtPassDate desc
end
这里的artClassId是冗余的,也可通过定义变量得到