Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
avmohankumar
Forum Newbie
Posts: 14 Joined: Fri Jun 08, 2007 7:20 am
Post
by avmohankumar » Tue Sep 04, 2007 8:57 am
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
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Tue Sep 04, 2007 9:01 am
Put quotes around date value.
There are 10 types of people in this world, those who understand binary and those who don't
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Tue Sep 04, 2007 9:57 am
Moved to "Databases" forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
califdon
Jack of Zircons
Posts: 4484 Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA
Post
by califdon » Tue Sep 04, 2007 6:16 pm
avmohankumar wrote: Code: Select all
$query = SELECT SUM(B) AS A FROM `maza` WHERE DATE = 2007-06-06 GROUP BY DATEIf 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.
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Wed Sep 05, 2007 11:00 am
DATE is reserved word.
Quote it or change field name.