I need to get a count of all users who have added 100 or more codes into our system. Simplified table structure is:
table: users
cols: id
table: log_users
cols: user_id, action, extra
My query is:
SELECT count() as total FROM users u WHERE (SELECT count() FROM log_users l WHERE l.user_id = u.id AND l.action = 'enter_code' AND l.extra LIKE '%- Valid') >= 100
I think there is a better way to do this but I can't think of it right now. ANy suggestions?
Thank You