On Tuesday 19 February 2002 10:07, Oliver Heinisch wrote: What would you expect the database to return????
You asked it to GROUP all the records with the same preis, that means it has to choose a value for each column of the record that is the result of each grouping, correct? So which of the (for example eleven (elf for you deutche;o)) different values of database.lfd did you want to have returned in your one resulting record? Obviously the database cannot stuff 11 values into one field.... You need something like select min(preis), max(lfd) .... or some other summary function, OR you need to GROUP BY preis,lfd. You simply cannot have it both ways. In fact (Monty are you listening!!!) MySQL needs to throw an error on this sort of query because it is relationally incorrect and the database engine cannot fullfill it correctly. For some odd reason though, human brains have a really hard time understanding this concept. If you want to really understand it, pretend to be a database and process a GROUP BY of the form he's having problems with, then you'll understand. ;o). > Hi Folks, > now sitting here for 5 hours trying to get these stupid sql-request > running, I decide to ask > the list. > > structual information of the database: > database.preis = decimal(12,2), > database.lfd=int(11), > database.typ=varchar(30), > database.marke=varchar(50) > > The following requests works > select min(preis) from database > also > select min(preis) from database where marke='marke' and typ not like 'R%' > and typ not like 'X%' > > but I have to get another value from the db so i choose > > select min(preis),lfd from database where marke='marke' > and typ not like 'R%' > and typ not like 'X%' > and typ not like 'C%' > group by preis > > this doesn´t bring the expected pair "preis / lfd" but all available > "preis/lfd" grouped ascending. > > Any idea, even if I´m shure that the select worked tonight. > TIA Oliver > > > --------------------------------------------------------------------- > 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 --------------------------------------------------------------------- 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