Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windowed functions and NEXT VALUE FOR functions do not support constants as ORDER BY clause expressions

When running this statement I get the error Windowed functions and NEXT VALUE FOR functions do not support constants as ORDER BY clause expressions.

SELECT * FROM (select ROW_NUMBER() OVER (ORDER BY 'publishdate DESC') as RowNum,
* FROM news WHERE publishdate <=getdate()) as info
WHERE RowNum > 0 AND RowNum <= (100)

I want to use this statement to retrieve a resultset in a paged gridview.

How to get this statement to run?

like image 365
Adam Avatar asked Nov 17 '13 19:11

Adam


1 Answers

SELECT * FROM (select ROW_NUMBER() OVER (ORDER BY publishdate DESC) as RowNum,
* FROM news WHERE publishdate <=getdate()) as info
WHERE RowNum > 0 AND RowNum <= (100)

You dont need the ' in (ORDER BY publishdate DESC)

like image 179
M.Ali Avatar answered Sep 28 '22 04:09

M.Ali