----- Original Message ----- 
From: "Scott Haneda" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 15, 2004 8:12 PM
Subject: Group by and results


> Are these 2 statements the same?
>
> tSql1 = select distinct foo, bar, baz from table
> tSql2 = select foo, bar, baz from table group by foo, bar, baz
>
> Why would I get different results?

I think you will always get the same results from those two statements.

However, you will find the second one considerably more useful in the sense
that you can add things to the Select clause without changing the rest of
the statement, e.g.

select foo, bar, baz, count(*), avg(bla)
from table
group by foo, bar, baz;

That example will work and give you all of the different combinations of
foo, bar, and baz that are found in the table PLUS the number of rows
containing each combination and the average of the 'bla' value for each of
those combinations. Good luck making the first statement return *that*
result.

Rhino



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to