Page 1 of 1

Using GROUP BY problem

Posted: Tue Sep 04, 2007 8:57 am
by avmohankumar
Dear Friends,

I want to sum up the field 'B'. By using this query

$query = SELECT SUM(B) AS A FROM `maza` WHERE DATE = 2007-06-06 GROUP BY DATE

But this is not working.


In that 'maza' tables are having two record on the date 2007-06-06. I want to sum up the value which date are group by same date.


Please suggest me,

Thanks in advance.

Regards,
Maza

Posted: Tue Sep 04, 2007 9:01 am
by VladSun
Put quotes around date value.

Posted: Tue Sep 04, 2007 9:57 am
by pickle
Moved to "Databases" forum.

Re: Using GROUP BY problem

Posted: Tue Sep 04, 2007 6:16 pm
by califdon
avmohankumar wrote:

Code: Select all

$query = SELECT SUM(B) AS A FROM `maza` WHERE DATE = 2007-06-06 GROUP BY DATE
If you're going to use just one date, then it makes no sense to GROUP BY date. However, if you are really going select on multiple dates, then it would.

Posted: Wed Sep 05, 2007 11:00 am
by xpgeek
DATE is reserved word.
Quote it or change field name.