1

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, (

Community
  • 1
  • 1
user1651888
  • 463
  • 2
  • 9
  • 25
  • possible duplicate of [MySql using correct syntax for the over clause](http://stackoverflow.com/questions/6292679/mysql-using-correct-syntax-for-the-over-clause) – Cyclonecode Feb 15 '15 at 11:44
  • What does the first `Select * from ` stand for? – sdespont Feb 15 '15 at 12:04
  • MySQL does not support window functions or common table expressions or `+` for string concatenation. Your query looks like SQL Server syntax. Perhaps you should run it in that database. – Gordon Linoff Feb 15 '15 at 12:47

0 Answers0