Neo*_*Neo 0 mysql select group-by
您好,我想按 file_serial 进行分组,但仅当file_serial > 1时,这意味着值不大于 1 的重复 file_serial

所以它应该看起来像

任何想法如何,那就太好了。谢谢。
一种方法是
select * from table
where file_serial > 1
group by file_title
having count(*) > 1
UNION
select * from table
Run Code Online (Sandbox Code Playgroud)
更新
仅当所有选择列具有相同值时,上述方法才有效。在这种情况下,您可能需要进行更改,因为同一标题的 file_id 不同。
select * from table
where file_serial > 1
group by file_title
having count(*) > 0
UNION
select * from table
file_serial <= 1
Run Code Online (Sandbox Code Playgroud)