This is a discussion on problems with Group by within the MySQL forums, part of the Database Server Software category; --> Hi, I made a news Archiv und I have a problem with 'Group by' in a SQLquery what I ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I made a news Archiv und I have a problem with 'Group by' in a SQLquery what I don't understand is what is going on, because for some months it works really fine and for other months it doesn't. in the months that don't work the following situation happens. The query gives me only the first dates and supresses the ohters. If I check the select without 'group by', I get all dates. I didn't see any differences between the entries in the database by the months what work and the months that don't work. I don't know what to do right now, only what I can see right now that the date and idnumber are not in order. i think the user, who have the entry rights didn't edit the datas, they delete them and wrote them new. but does it really matter, cause the query takes the datas corectly without 'group by'only the Group by doesn't work. Beside english is not my motherlanguage I hope you can undertstand my problem. thanks alot for any help bye Matth |
| |||
| On Thu, 13 Mar 2008 13:47:23 +0100, Matthias Roeder <info@vmind.de> wrote: > Hi, > > I made a news Archiv und I have a problem with 'Group by' in a SQLquery > what I don't understand is what is going on, > because for some months it works really fine and for other months it > doesn't. > in the months that don't work the following situation happens. > The query gives me only the first dates and supresses the ohters. > If I check the select without 'group by', I get all dates. > > I didn't see any differences between the entries in the database > by the months what work and the months that don't work. > > I don't know what to do right now, only what I can see right now that > the date and idnumber are not in order. > i think the user, who have the entry rights didn't edit the datas, > they delete them and wrote them new. > > but does it really matter, cause the query takes the datas corectly > without 'group by'only the Group by doesn't work. > > Beside english is not my motherlanguage I hope you can undertstand my > problem. We can't understand your problem without: 1) A description of the database (SHOW CREATE TABLE tablename) 2) The actual query you're using. -- Rik Wasmus |
| ||||
| > We can't understand your problem without: > 1) A description of the database (SHOW CREATE TABLE tablename) > 2) The actual query you're using. Hi, my table is CREATE TABLE `news2` ( `newsid` int(11) NOT NULL auto_increment, `datum` date NOT NULL, `kommentar` text collate latin1_german2_ci NOT NULL, `ueberschrift` varchar(200) collate latin1_german2_ci NOT NULL default PRIMARY KEY (`ID`) ) my query is SELECT DAYOFMONTH( `datum` ) AS Tag, MONTH( `datum` ) AS `Monat` , YEAR( `datum` ) AS `Jahr` FROM `news2` GROUP BY Jahr, Monat ORDER BY Jahr DESC , Monat DESC |