Reputation: 245
This stored procedure doesn't perform descending order of data I don't know why !
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
this is the result when I give the @Upperbound and @LowerBound values
aricleid 54 55 56 57 . . .
Upvotes: 1
Views: 64
Reputation: 28403
Try like this
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
Upvotes: 1
Reputation: 15387
Try this
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
Upvotes: 1