November 23, 2010 at 4:55 am
Hi,
I´m using SQL 2005 and what is wrong with the query below?
SELECT MAX( RowNumber ) FROM
(
SELECT
ROW_NUMBER() OVER (ORDER BY MSG_DTM_LASTSTATUSTIME DESC) as RowNumber
FROM
Message_MSG msg with(nolock)
)
Thanks in advance,
Fernando
November 23, 2010 at 5:10 am
try this
SELECT MAX( RowNumber ) FROM
(
SELECT
ROW_NUMBER() OVER (ORDER BY MSG_DTM_LASTSTATUSTIME DESC) as RowNumber
FROM
Message_MSG msg with(nolock)
) A
November 23, 2010 at 5:11 am
Thank you very much!
November 23, 2010 at 5:13 am
Just add an alias:
SELECT MAX( RowNumber ) FROM
(
SELECT
ROW_NUMBER() OVER (ORDER BY MSG_DTM_LASTSTATUSTIME DESC) as RowNumber
FROM
Message_MSG msg with(nolock)
) AS x
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply