php - post the second duplicate in a table -
i have following statement
select whatweek, username, team weekpicks group team, username having count(*) > 1 order 'whatweek' asc
the out put find of duplicates in table user list not output second occurrence. times post 1st occurrence , others 2nd occurrence. need post second occurrence.
you may calculate needed whatweek in subquery
select ( select whatweek weekpicks t t.username = weekpicks.username , t.team = weekpicks.team order whatweek desc limit 1) `needed_whatweek`, username, team weekpicks group team, username having count(*) > 1
edit or use max(), preffer think:
select max(whatweek), username, team weekpicks group team, username having count(*) > 1
Comments
Post a Comment