Solarpitch Posted January 12, 2009 Share Posted January 12, 2009 Hey Guys, I have a table in my database that stores a list of transactions that take place on a POS system. I need to generate a report which will tell the client how much they made for each hour of the day: 6am - 7am -> €450.00 7am - 8am -> €687.00 and son on... This is a cut down example of my database and how the date and time format is stored... DATE ITEM PRICE TIME 20071006 budwiser 4.60 06:31:01 20071006 coke 2.30 06:31:01 20071006 guinness 4.30 06:42:05 20071006 cider 4.60 07:02:16 20071006 crisps 0.70 07:02:16 I'm not quite sure what to do with the query. I know how to get the sum of a column and all but its a little confusing when I need to loop through the results and calculate the total for each hour. :-\ Link to comment https://forums.phpfreaks.com/topic/140546-query-needed-with-gathering-data-for-a-report/ Share on other sites More sharing options...
Solarpitch Posted January 12, 2009 Author Share Posted January 12, 2009 Can anyone offer a little help with this. Really just a starting point is all I need. Link to comment https://forums.phpfreaks.com/topic/140546-query-needed-with-gathering-data-for-a-report/#findComment-735721 Share on other sites More sharing options...
ngreenwood6 Posted January 13, 2009 Share Posted January 13, 2009 I don't know if this will work or not but maybe it will help you get started. SELECT SUM(price) as hour_total FROM table WHERE time < 10:00:00 AND time > 09:00:00 That is just an example. Link to comment https://forums.phpfreaks.com/topic/140546-query-needed-with-gathering-data-for-a-report/#findComment-735742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.