I have two tables in the following format
Users:
UserID Name State
100 ABC Active
200 DEF Active
300 GHI Inactive
Transactions:
UserID TransactionDate TransactionType Amount
100 2020-01-01 Gas 100
100 2020-01-01 Grocery 50
100 2020-05-01 Grocery 20
200 2020-01-01 Gas 50
200 2020-01-01 Gas 15
300 2020-05-01 Grocery 20
I want to get a result as follows:
TransactionType Count
Gas 3
Grocery 2
Essentially, I want to select only users that are Active from Users table and for these users, count the number of transactions that happend in the Transactions table.
I am an sql newbie, and tried some joins and counts, but w/o success, any idea how I can get this to work?
Thanks!