This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » SQL and Databases » Display daily totals for previous weeks
Reply

Display daily totals for previous weeks

john henderson
Member



Since: 05 Feb 2009
Posts: 5
Posted 03 Jul 2009 20:29:54

Hi,

I wonder if there is a solution to my query; I need to be able to produce a weekly report that will display all daily totals for that week or any previous week. I have toyed around with the weekday() function and the Week() function, but I don't know mysql well enough to produce the required results. []

Here is my sql statement...

SELECT *, sum(payments.payment) as totpay1, sum(payments.payment2) as totpay2, sum(payments.payment+payments.payment2) as totalcash, operative, week(stampoperative), weekday(stampoperative)
FROM customers, payments
WHERE weekday(stampoperative) ='1' and WEEK(stampoperative) = WEEK(now()) and customers.customerid = payments.customerid and paid='1' and code<>
'No Access' and code<>'DPP'

What I thought I could do was use the week() function to find the week number and then use the wekday() to pull all records for that day.

So as an example I could have week 13 and search for day 1, being a Monday or day 2 being a Tuesday etc, etc. It would also be helpful to be able to display the actual date for week 13 day 1 too. []

Any guidance would be very much appreciated

Thanks in advance

John Henderson []

Hi,

I wonder if there is a solution to my query; I need to be able to produce a weekly report that will display all daily totals for that week or any previous week. I have toyed around with the weekday() function and the Week() function, but I don't know mysql well enough to produce the required results. []

Here is my sql statement...

SELECT *, sum(payments.payment) as totpay1, sum(payments.payment2) as totpay2, sum(payments.payment+payments.payment2) as totalcash, operative, week(stampoperative), weekday(stampoperative)
FROM customers, payments
WHERE weekday(stampoperative) ='1' and WEEK(stampoperative) = WEEK(now()) and customers.customerid = payments.customerid and paid='1' and code<>
'No Access' and code<>'DPP'

What I thought I could do was use the week() function to find the week number and then use the wekday() to pull all records for that day.

So as an example I could have week 13 and search for day 1, being a Monday or day 2 being a Tuesday etc, etc. It would also be helpful to be able to display the actual date for week 13 day 1 too. []

Any guidance would be very much appreciated

Thanks in advance

John Henderson []

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency