Click to See Complete Forum and Search --> : Query Needed
Hi Friends
I am working to draw a graph . I need to get the data monthly, for example JAN total hours FEB total hours ,
How to write the query get the total values per month?
Advance thanks for your reply.
Phill Pafford
09-10-2008, 03:02 PM
well without seeing some of the table structure I can only guess.
SELECT hours
FROM table_name
WHERE date BETWEEN 'Start Time' AND 'End Time' /* Start & End time would be something like this: 2008-09-01 00:00:00 between single quotes */
GROUP BY month
Hopes this helps
This query get one month details .I need to get one year value for single query. values get each month .
thanks
Phill Pafford
09-11-2008, 08:12 AM
Yes the query above will return 12 results (just increase the date range), each month being grouped together.
Still without seeing the table structure the query I write is useless, it only gives you an IDEA on how to do things.
if you wanted to have one result with the total yearly amount you could do something like this
SELECT SUM(hours)
FROM table_name
WHERE date BETWEEN '2008-01-01 00:00:00' AND '2009-01-01 00:00:00'
/* Start & End time would be something like this: 2008-09-01 00:00:00 between single quotes */