TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Riddhi Valecha
443
3.3k
413k
Paging using ROW_NUMBER() in SQL
Oct 29 2014 3:12 AM
Hi all..
I have a table -
ID
EmpCode
FName
LName
CreatedBy
CreatedOn
1
123
Ketan
Jadav
456
2013-09-09
2
456
Suresh
Sharma
456
2013-09-09
3
876
Lakshmi
Rao
456
2013-09-09
4
489
Reshma
Gandhi
456
2013-09-09
I have to load this table as -
select USERS.EmpCode, USERS.FName,USERS.LName,
(SELECT CONVERT(varchar(max),a.FName )+' '+CONVERT(varchar(max),a.LName )
from TBL_USERMASTER a
where a.EmpCode=CONVERT(numeric(25,0),USERS.TeamLead))as CreatedBy,
CONVERT(VARCHAR(10),TBL_USERMASTER.CreatedOn ,103) AS CreatedOn from USERS order by TBL_USERMASTER.EmpCode desc
I get the output as -
EmpCode
Fname
LName
CreatedBy
CreatedOn
123
Ketan
Jadav
Suresh Sharma
2013-09-09
456
Suresh
Sharma
Suresh Sharma
2013-09-09
876
Lakshmi
Rao
Suresh Sharma
2013-09-09
489
Reshma
Gandhi
Suresh Sharma
2013-09-09
Now, How do I implement paging in this query using Row_Number() ??
Eg -
'select * from (select ROW_NUMBER() over (order by Table1.ID) as ROW,
Table1.Col1 , Table1.Col2, ,CONVERT(VARCHAR(10),Table1.CreatedOn ,103)
AS CreatedOn , Table1.Col3
from Table1 as Table1Rows where ROW BETWEEN 1 and 50 order byTable1.ID'
-------------
I am not able to do paging in this query.
Reply
Answers (
1
)
Dropdown property differences
How to print <div>............</div> content from page