My data looks like this:

queryable_type   queryable_id 
User             1 
User             2
User             2

I'd like to return dupes so that my result would look like this:

queryable_type  queryable_id count 
User            2            2

I'm assuming some multiple group by but it wasn't working.


This is a most basic group by query:

select queryable_type, queryable_id, count(*)
from the_table
group by queryable_type, queryable_id 
having count(*) > 1
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.