Skip to content
Advertisement

Get users which have multiple entries in multiple categories

The following query returns no results, I’m guessing because I’m ‘and’ing twice in a row on the same value. If I change it to ‘or’, then I get 2/3rds of what I need but I need users that have multiple entries in multiple categories – is there a way to effectively say “give me the users who have count greater than 1 in category A AND category B” in SQL?

Advertisement

Answer

Use aggregation:

As you have written the query, the Users table is not necessary — unless there are “entities” in transactions that are not users, so the join is for filtering.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement