473,508 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wrong summation using php to read mysql database

want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:
$query = mysql_query("select distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,JobDateTo,endYear,NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Date('$startdate') and JobDateTo=('$enddate')");

thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!

Aug 21 '07 #1
2 1247
Asembereng wrote:
want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:
$query = mysql_query("select distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,JobDateTo,endYear,NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Date('$startdate') and JobDateTo=('$enddate')");

thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!
Since you're asking how to compose a SQL query, I suggest you try a SQL
newsgroup - like comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 21 '07 #2
On 21 Aug, 13:02, Asembereng <mljarj...@gmail.comwrote:
want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:

$query = mysql_query("select distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,JobDateTo,endYear,NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Date('$startdate') and JobDateTo=('$enddate')");

thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!
Whilst you should be asking this in an SQL group...

Which of the fields
TimeType, JobDateFrom, endYear, NcType
contains months?

Aug 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1764
by: cocoalearner | last post by:
I am serving a website using apache. All the php and mysql code I have written works, except for one thing. When I try to create a database named M#2 using the following call, no database is...
0
2137
by: Hugo Fjelsted Alrøe | last post by:
I am fairly new at MySQL, so please excuse any ignorance. We are using MySQL (version 3.23.48) in connection with an Eprints = archive. We have non-english deposits in the archive, and...
0
2748
by: Bennett Haselton | last post by:
I'm trying to port my MySQL tables for a database called "tracerlock" from one server to another. On the old server, in the /var/lib/mysql/tracerlock directory, there was a ".MYD", ".MYI" and...
7
33375
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I...
17
2004
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a...
1
1402
by: crazydrummer | last post by:
hi everyone, fairly new to access and VBA, but have fundamental knowledge. as part of a college project i am building a database that records "downtime" for machines in a company. the...
3
2135
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
22
2000
by: davy.zou | last post by:
I found the code for a program that is suppose to be able to work out the sumation of i from 1 to a certain integer n. however, when I implemented to code into Visual C++, it doesn't work. The...
221
366982
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.