How can I find the team with the most active sellers (highest number of software sales per user per day)? I wanted to do something like this query but it doesn't feel quiet right
SELECT users.team_id, count(*) as sales FROM users
INNER JOIN activity ON users.user_id = activity.user_id
WHERE activity.sales = software
GROUP BY users.team_id
ORDER BY sale DESC
My user table looks like this:
user_id team_id
0 62
1 32
2 21
While my activity table looks like this:
user_id sale_date sale
1 2019-05-02 11:02:39 hardware
2 2018-05-02 11:02:53 software
2 2019-06-02 11:42:33 software