此存储过程不执行数据的降序我不知道为什么!
BEGIN
SET nocount ON;
WITH ordereddata
AS (SELECT *,
rn = Row_number()
OVER (
ORDER BY articleid )
FROM articles)
SELECT *
FROM ordereddata
WHERE rn <= @UpperBound
AND rn >= @LowerBound
ORDER BY articleid DESC
END
这是我给@Upperbound和@LowerBound值
时的结果aricleid 54 55 56 57。 。
答案 0 :(得分:1)
试试这个
BEGIN
SET NOCOUNT ON;
WITH OrderedData
as (
select * , rn = ROW_NUMBER() OVER (ORDER BY articleid desc ) FROM articles
)
select * from OrderedData
where rn <= @UpperBound AND rn >= @LowerBound
ORDER BY articleid desc
END
答案 1 :(得分:1)
试试这个
BEGIN
SET NOCOUNT ON;
WITH OrderedData
as (
select * , rn = ROW_NUMBER() OVER (ORDER BY articleid) FROM articles
)
select * from OrderedData
where rn <= @UpperBound AND rn >= @LowerBound
ORDER BY articleid desc
END