Re: Group By?!
From: Brendan Reynolds (brenreyn)
Date: 02/02/05
- Next message: RMarmion: "Need help with making SourceSafe work with Access 2003"
- Previous message: Ken Snell [MVP]: "Re: Group By?!"
- In reply to: Newb-Lost-In-A-Sea-Of-Tables: "Re: Group By?!"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 2 Feb 2005 15:44:40 -0000
"Newb-Lost-In-A-Sea-Of-Tables"
<Newb-Lost-In-A-Sea-Of-Tables@discussions.microsoft.com> wrote in message
news:64D84DEA-2F4A-44DA-93B7-4767DADFAFAC@microsoft.com...
<snip>
> In this statement, the group by clause added shortens the amount of data
> displayed. If I were to take out that huge group by clause, I get more
> data
> displayed. I wanted to know why the Group By clause lessens the amount of
> data shown.
Let's try and demonstrate the principle with a simpler query. Take the
Orders table from the Northwind database. Create a simple query that selects
the CustomerID and EmployeeID like so ...
SELECT Orders.CustomerID, Orders.EmployeeID
FROM Orders;
This query will return one row for every record in the Orders table, 830
rows in my copy of Northwind.
Now lets group by CustomerID and EmployeeID, like so ...
SELECT Orders.CustomerID, Orders.EmployeeID
FROM Orders
GROUP BY Orders.CustomerID, Orders.EmployeeID;
This query will return one row for each unique combination of CustomerID and
EmployeeID, 465 rows in my copy of Northwind. For example, in my copy of
Northwind, Nancy Davolio has taken two orders for customer 'Alfreds
Futterkiste'. The original query, without grouping, will return these two
rows. The second query, with grouping, will return one row for the
combination Alfreds Futterkiste/Nancy Davolio, and one row for each other
unique combination of CustomerID and Employee.
-- Brendan Reynolds (MVP)
- Next message: RMarmion: "Need help with making SourceSafe work with Access 2003"
- Previous message: Ken Snell [MVP]: "Re: Group By?!"
- In reply to: Newb-Lost-In-A-Sea-Of-Tables: "Re: Group By?!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|