Azure SQL Database
An Azure relational database service.
6,326 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
I am writing below using With clause but i am getting error "Incorrect syntax near RNum"
WITH CTE AS
(SELECT *,DENSE_RANK()OVER(ORDER BY L_key DESC)) as RNum
FROM DBO.Rep_Def_TMP
Please suggest.
Thanks
Your SQL statement is wrong. A WITH clause must start with a semicolon. And a WITH is a kind on inline view, which you use/query later in the SQL statement like here SELECT * FROM CTE:
;WITH CTE AS
(SELECT *, DENSE_RANK() OVER(ORDER BY L_key DESC) as RNum
FROM DBO.Rep_Def_TMP)
SELECT *
FROM CTE