Jump to content

Recommended Posts

OK, i am a bit confused how to attempt this, i have a few ideas, but none are very efficient.

 

I have a table in a mySQL database called "tblOrderArchive" which is a table of orders on my site, i have a graph class which requires two arrays of values one for X axis one for Y, ok easy enough so far, but the scenario is as follows:

 

I need to make a graph as follows:

X axis - Week by Week

Y axis - Orders Taken

Graphname - "Orders per week"

 

To do so i need to generate arrays as follows:

xAxisData('21/05/2006','28/05/2006')

YAxisData('234','242')

 

etc

 

What would be the best way to get this data from my table in a week by week format? the table Schema is as follows:

 

id - int

client_fk - int

date - DataTime Type

htmlField - text

value - Decimal(11,2)

 

Any help would be VERY gratefull.  ;D

 

Regards,

 

HeavenCore

There's a YEARWEEK() MySQL function that you can use to group your dates into weeks.

 

Something like:

SELECT YEARWEEK(date) AS week,MIN(date),SUM(value) FROM tblOrderArchive GROUP BY week

# or:

SELECT YEARWEEK(date) AS week,* FROM tblOrderArchive ORDER BY week,date

 

...depending on what you want.

thanks alot m8!

 

i adpated that as follows:

 

SELECT YEARWEEK( date ) AS Week, Sum( total ) 
FROM orders
GROUP BY Week

 

However the date Returned is listed as

 

yyyyww eg 3rd week in 2007 would be 200703

 

i'm guessing date() can be used to convert this to a more recognisable date eg: 21/01/2007 dd/mm/yy?

 

Can you shed any light on this please?

 

Cheers. :D

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.