mysql - SQL - Selecting data that is the same in multiple rows for a particular key -
i have dataset below:
key     user     step --------------------- 123     geoff    1 123     geoff    2 123     john     3 456     jane     1 456     jane     2 456     jane     3 456     jane     4 what need select key user same in steps (there can between 1 5 steps in dataset). in example above need query return key 456. appreciated!
instead of comparing min(user) , max(user), can well:
select tablename.key tablename group tablename.key having count(distinct d.user) = 1; count(distinct d.user) should more descriptive use case.
Comments
Post a Comment