Mailinglisten-Archive |
Hallo Olli, >... > Ich moechte an folgender, beispielhafter Tabelle > > router ; frames_sent ; time_stamp > > zu jedem router die max(frames_sent) *mit* Angabe des dazugehoerigen > time_stamp haben. > ... kann man fast als RTFM Frage bezeichnen. Schau Dir doch mal das untenstehende Beispiel aus dem Handbuch an. 9.3.4 The Rows Holding the Group-wise Maximum of a CertainField For each article, find the dealer(s) with the most expensive price." ... In MySQL it's best do it in several steps: 1. Get the list of (article,maxprice). 2. For each article get the corresponding rows that have the stored maximum price. This can easily be done with a temporary table: CREATE TEMPORARY TABLE tmp ( article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL, price DOUBLE(16,2) DEFAULT '0.00' NOT NULL); LOCK TABLES shop read; INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article; SELECT shop.article, dealer, price FROM shop, tmp WHERE shop.article=tmp.article AND shop.price=tmp.price; UNLOCK TABLES; DROP TABLE tmp; Gruss, Michael --- *** Weitere Infos zur Mailingliste und MySQL unter http://www.4t2.com/mysql
php::bar PHP Wiki - Listenarchive