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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -