Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Range and SUM

Status
Not open for further replies.

TamedTech

IS-IT--Management
May 3, 2005
998
GB
Hello Guys,

This is somthing i've not worked with before so thought i'd come on here for a little help.

I have a database with a whole stack of records, one for each day which is generated by a script on the server.

I am giving my users the ability to choose a startDate and endDate for thier report to be built, i then want it to take all records from the database between those dates and Add the values of all the returned rows together and pass them as a single row back to me.

Is this somthing that can be achieved in MySQL? or will i have to just run a standard query to return the results and then have my SeverSide scripts so the math?

Thanks

Rob
 
It can certainly be done:
[tt]
SELECT SUM(col1) total1, SUM(col2) total2, SUM(col3) total3
FROM tblname
WHERE datefield BETWEEN '2006-06-01' AND '2006-06-30'
[/tt]
 
Thats excelent thanks tony, I'll give it a run through shortly and let you know how I get on with it.

Thanks,

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top