473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQL rows to columns plus calculations

Hi there,

My data looks like this:
PostCode,Product,Month,Sales
AB10,Product1,201106,1212
AB10,Product2,201106,3455
AB11,Product1,201106,3443
AB11,Product2,201106,1344

I need to transform it to do this:

Postcode,Product,Total3MonthSales
AB10,Product1,1121212
AB10,Product2,234234234
AB11,Product1,678678
AB11,Product2,234234

So for each postcode, and each product, I need to take the last 3 months of sales and add them together.

Can anyone help?

Thanks
Jul 7 '11 #1
1 1495
Rabbit
12,516 Expert Mod 8TB
Use an aggregate sum query grouping by postcode and product and limit by the last three months of data.
Jul 7 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tim | last post by:
Hello, This problem perplexes me and I hope that someone has done something efficient. Take for example the data in the MASTER..SYSPERFINFO: SELECT CAST(RTRIM(INSTANCE_NAME) AS VARCHAR(15)),...
2
by: muntyanu | last post by:
Hi all, I have problem when merging existing DataTable into new dataset. DataSet ds = new DataSet(); while ( done ) { // fill myCustomDataSet.MyTable with data ds.Merge(...
2
by: J055 | last post by:
Hi I've been looking into different ways of formatting columns/rows in the GridView control. I realize now, I think, that once the datasource is bound to the control the original column type...
1
by: pinkyrose | last post by:
Hi there, i need some help in accessing a the ith row in a NxM array in vba. More specifically i have an NxM array called prices and i want to find the average of each row ,as well as the mean...
3
by: Rambaldi | last post by:
Although i'm working on ASP.net, i think the problem i'm facing is related to my javascript function so i hope i create the thread in the right section. My goal is to create a table dynamically,...
0
by: yoav.sagi | last post by:
hi, i am Inheriting from TableLayoutPane with a designer that inherits from ParentControlDesigner ..i would like to allow the user to resize the columns and rows ..All rows and columns SizeType =...
6
by: viki1967 | last post by:
Hi all. I need your help. I realize this script and I do not know where to begin: 1) A simple grid rows / columns. 2) The first column contain an input type = "checkbox" 3) When select...
3
by: ronakinuk | last post by:
how can i unhide rows/columns in excel 2007
1
by: nawedita | last post by:
Hi everyone how i add and delete rows,and columns(textbox,dropdown) dynamically onclick button and store data in database with insert,update,delete record.that support all browsers.Because i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.