MySQL Forums
Forum List  »  Newbie

Re: QUERY HELP
Posted by: Peter Brawley
Date: December 21, 2016 11:55AM

This query ...
select user_id,sum(amount) total
from table
group by user_id;
... gets you sums grouped by user_id, so this query ...
select user_id
from (
  select user_id,sum(amount) as total
  from table
  group by user_id
) x
where x,total=5000;
... gets you user_ids with sums equal to 5000.

Options: ReplyQuote


Subject
Written By
Posted
December 21, 2016 11:28AM
Re: QUERY HELP
December 21, 2016 11:55AM
December 21, 2016 12:06PM
December 21, 2016 01:55PM
December 21, 2016 03:39PM
December 21, 2016 12:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.