我正在使用partition by获取重复的行,并且此查询在mysql5.7中返回语法错误
select column1,ROW_NUMBER() OVER (PARTITION BY column2, column3 ORDER BY column2 DESC) as RowNumber
from tableA
错误:
ERROR 1064 (42000): 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 column1, column2 ' at line 1
或其他任何查询
或者其他任何查询可重新运行仅重复的行(第2列和第3列分别包含相同的值),在这种情况下,输出将返回第1、3、5、6行
感谢您的帮助。
答案 0 :(得分:1)
具有EXISTS:
select t.* from tablename t
where exists (
select 1 from tablename
where column1 <> t.column1 and column2 = t.column2 and column3 = t.column3
)