Hi there,
I am quite new to MYSQL and come from a MS Access background.
I have a sales transaction table and can create a query that will give me aggregate totals for a certain period of time for various product groups.
This will output something like the following...
What I am looking for is a query that will provide another column of data that shows last years sales totals for the various groups.
In Access I would just include another aggregate query in my query to display that value as another column...which leads me to suspect I need a sub-query for the different period of time.
I can't find any examples to help me..so I hope someone has some ideas for me.
Thanks in advance.
Peter.
Remember- It's nice to be important,
but it's important to be nice
I am quite new to MYSQL and come from a MS Access background.
I have a sales transaction table and can create a query that will give me aggregate totals for a certain period of time for various product groups.
Code:
SELECT
groupslink.Group as GroupName,
sum(Quantity) as QuantityTotal,
sum(Sale) as SaleTotal
FROM groupslink INNER JOIN translog
ON groupslink.GroupsGroup = translog.Group
WHERE translog.Date between '2008-02-01' and '2008-02-28'
and translog.Store = 1
GROUP BY groupslink.Group
This will output something like the following...
Code:
GroupName QuantityTotal SaleTotal
Accessories 10 100.00
Cameras 15 2300.00
etc.
What I am looking for is a query that will provide another column of data that shows last years sales totals for the various groups.
In Access I would just include another aggregate query in my query to display that value as another column...which leads me to suspect I need a sub-query for the different period of time.
I can't find any examples to help me..so I hope someone has some ideas for me.
Thanks in advance.
Peter.
Remember- It's nice to be important,
but it's important to be nice