Sign in to follow this  

[web] [MySQL4] Doing a "where" after a "group by"

This topic is 4088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a query that looks something like this: select person.*, sum(item.amount) as Total from person inner join item on item.personid = person.personid group by person.personid This sums up the total number of items for each person and returns it alongside the person record. What I want to do is something like this: select person.*, sum(item.amount) as Total from person inner join item on item.personid = person.personid group by person.personid where Total > 100 The problem is, I can't filter by aggregate fields. I'm using MySQL 4, so I can't use a subquery to get the job done. I have to do this in MySQL rather than manually in my PHP because I intend to do paging with "limit". How would I get this done?

Share this post


Link to post
Share on other sites

This topic is 4088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this