----- Original Message ----- 
From: "Tobias K. Tobiasen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 04, 2002 6:46 PM
Subject: Group by?


> Hello
> 
> I think the gruop by is behaving strange. Could someone please explain 
> this or maybe point me to a definition of the group by. (Inspired by 
> http://www.mysql.org/doc/E/x/Examples.html).
> 
> 
> CREATE TABLE shop (
>   article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
>   dealer  CHAR(20)                 DEFAULT ''     NOT NULL,
>   price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL,
>   PRIMARY KEY(article, dealer));
> 
> INSERT INTO shop VALUES
> (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),(3,'C',1.69),
> (3,'D',1.25),(4,'D',19.95);
> 
> mysql> SELECT * FROM shop;
> 
> +---------+--------+-------+
> | article | dealer | price |
> +---------+--------+-------+
> |    0001 | A      |  3.45 |
> |    0001 | B      |  3.99 |
> |    0002 | A      | 10.99 |
> |    0003 | B      |  1.45 |
> |    0003 | C      |  1.69 |
> |    0003 | D      |  1.25 |
> |    0004 | D      | 19.95 |
> +---------+--------+-------+
> 7 rows in set (0.00 sec)
> 
> mysql> select * from shop GROUP BY article;
> +---------+--------+-------+
> | article | dealer | price |
> +---------+--------+-------+
> |    0001 | A      |  3.45 |
> |    0002 | A      | 10.99 |
> |    0003 | B      |  1.45 |
> |    0004 | D      | 19.95 |
> +---------+--------+-------+
> 4 rows in set (0.00 sec)
> 
> QUESTION: I had expected 7 rows - where did the rest go?

Try SELECT * FROM shop GROUP BY article,dealer;

(same thing for the rest of queries)

Regards,

Jocelyn Fournier
Presence-PC


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to