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
Bineeshcp Viswanath
NA
140
39.4k
sql query to get server side data -paging by date desc
May 21 2019 3:16 AM
Hello All,
I wrote a sql query to get custom paging in asp.net gridview. I am getting the result in gridview as expected but there is a discrepancy - record not in sorted in descending date.
I need your help to find a solution to write below sql query in descending date order.
SET
NOCOUNT
ON
;
SELECT
ROW_NUMBER() OVER
(
ORDER
BY
[CustomerID]
ASC
)
AS
RowNumber,
tblActionDetaills.FID,tblActionDetaills.VID,tblActionDetaills.AdminUserID,
tblImageDetails.Filepath, IsRead,
Convert
(
varchar
(20),EventDate,103)
as
EventDate,
REPLACE
(
SUBSTRING
(
CONVERT
(nvarchar(128),EventDate, 109), 12 , 128),
':000'
,
' '
)
as
EventTime,
Description
INTO
#Results
FROM
tblActionDetaills
inner
join
tblVilla
on
tblVilla.VID=tblActionDetaills.VID
inner
join
tblUserLogin
on
tblUserLogin.UserID=tblVilla.UserID
left
join
tblImageDetails
on
tblImageDetails.FID=tblActionDetaills.FID
WHERE
tblUserLogin.UserID=
'AA01'
order
by
Convert
(datetime,EventDate,103)
desc
SELECT
'10'
=
COUNT
(*)
FROM
#Results
SELECT
*
FROM
#Results
WHERE
RowNumber
BETWEEN
(1 -1) * 10 + 1
AND
(((1 -1) * 10 + 1) + 10) - 1
order
by
Convert
(datetime,EventDate,103)
desc
DROP
TABLE
#Results
Reply
Answers (
4
)
Import Export in SQL server 2017
Date Difference