I get syntax error using MySQL on the following sql statement:
Select * from
(
Select *, ROW_NUMBER() OVER( PARTITION BY id ORDER BY td asc) rn FROM emp
),cte2 AS (
SELECT c2.*, CASE WHEN c.req_type != c2.req_type THEN 'Req changed from'+CONVERT(VARCHAR,c2.req_type)+' to '+CONVERT(VARCHAR,c.req_type) ELSE '' END AS reqc,
CASE WHEN c.token != c2.token THEN 'Token changed from' +CONVERT(VARCHAR,c2.token)+' to '+CONVERT(VARCHAR,c.token) ELSE '' END AS tokenc
FROM cte c INNER join cte c2 ON c2.rn+1 = c.rn
)
Can someone tell what is wrong here ? I get Error Code:
1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(PARTITION BY id ORDER BY td asc) rn FROM emp) as cte, (