wilflife
asked on
SQL
Hi,
I have a table with about 10 columns
Product
Country
Date In text format JAN-09
Week Number
Product SubCategory
Product Description
Unit measure.
Units Sold
Vol Sold
I would like to do two things...
Aggregate up all the sales by summing units sold for each month
And also sum up the volume sold.
This should be returned by the same query.
All the other columns should be brought across with no calcs ie the units and this suming should be done at the month level so i have to split the month off from the string as well.
Thanks for help...
I have a table with about 10 columns
Product
Country
Date In text format JAN-09
Week Number
Product SubCategory
Product Description
Unit measure.
Units Sold
Vol Sold
I would like to do two things...
Aggregate up all the sales by summing units sold for each month
And also sum up the volume sold.
This should be returned by the same query.
All the other columns should be brought across with no calcs ie the units and this suming should be done at the month level so i have to split the month off from the string as well.
Thanks for help...
ASKER
Will this give me it all grouped by the month.... as i know when i use the sum i have to group by everything but effectively i only want it grouped by the month and all other columns simply transported across... will this simple sql do it?
Thanks.
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Since you want months, you will need to drop the week field from your query.
select
Product,
Country,
Product SubCategory,
Product Description,
Unit measure.
Date, -- In text format JAN-09
UnitsSold = sum(Units Sold),
VolSold = sum(Vol Sold)
from tablename1
group by
Product,
Country,
Product SubCategory,
Product Description,
Unit measure.
Date
Hope this helps.