I am trying to paginate my page,
I am using this query :
Select *
From (
Select Row_.*,
Rownum Rownum_
From (
Select Distinct(Qa.Question_Id) As Id
From Question Qa
Where Qa.Is_Deleted = 'F'
And Qa.Is_Answered = 'T'
Order By Qa.Like_Count Desc
) Row_
Where Rownum <= 10
) Where Rownum_ > 0
My result is
10662 1
11315 2
11142 3
13591 4
12344 5
12264 6
12186 7
11938 8
11183 9
10842 10
When i am trying to paginate in 5 max result solution is
Select *
From (
Select Row_.*,
Rownum Rownum_
From (
Select Distinct(Qa.Question_Id) As Id
From Question Qa
Where Qa.Is_Deleted = 'F'
And Qa.Is_Answered = 'T'
Order By Qa.Like_Count Desc
) Row_
Where Rownum <= 5
) Where Rownum_ > 0
Result :
10662 1
11315 2
11142 3
11183 4
10842 5
And:
Select *
From (
Select Row_.*,
Rownum Rownum_
From (
Select Distinct(Qa.Question_Id) As Id
From Question Qa
Where Qa.Is_Deleted = 'F'
And Qa.Is_Answered = 'T'
Order By Qa.Like_Count Desc
) Row_
Where Rownum <= 10
) Where Rownum_ > 5
Result
12264 6
12186 7
11938 8
11183 9
10842 10
In second and third script, Solution in third script 9,10 rownum is equal with second script 4,5.
Why the solution is not like the first query? How can i paginate my query properly?