tags:

views:

29

answers:

1

Hi all,
What does a multiple groups query actually accomplish? For example, if you have

SELECT * FROM table WHERE id = $id GROUP BY date, quantity, buyer;

What does that mean in plain English? I know what it means to "Group by date", but is "group by date, quantity" like a 2-d array?

Thanks.

+3  A: 

It means ALL of the GROUP BY elements have to be identical in order for the records to be grouped.

For example, using:

GROUP BY start_date, category_id

Would keep rows with the same start date but different category_id as separate returned elements. Rows would need to have the same exact start_date and category_id in order to be grouped together.

AvatarKava