Azure SQL Database
An Azure relational database service.
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
An Azure relational database service.
Answer accepted by question author
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