Jump to content

Recommended Posts

I assume you really mean all the sales for the month of July in 2012 (or some particular year), correct? If you had data over multiple years you wouldn't want the sales total for July from all years.

 

So, you need to extract the month and year from the date field and GROUP BY those two values (if getting the totals for all year/month combos:

 

SELECT SUM(total), MONTH(date_created) as month, YEAR(date_created) as YEAR
FROM table_name
GROUP BY year, month

Thanks so much. I however would want the final php outcome to look something like this

 

Month      Total

==============

July 12            1000

Aug 12            850

 

etc...

I'm 100% sure that you don't have an idea what you're doing, right?  ;)

Thanks so much. I however would want the final php outcome to look something like this

 

Month      Total

==============

July 12            1000

Aug 12            850

 

etc...

 

OK, how does the first solution I provided not work for that?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.