473,671 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transpose data usign Transform-Pivot

Hi,
I Have data stored with the following structure:
Version Product Account Jan Feb Mar Apr May ... Dec
1 Brand1 403050 100 200 150 500 400 100
Id'like to transform it in the following table:
Version Product Account Month Amount
1 Brand1 403050 01 100
1 Brand1 403050 02 200
1 Brand1 403050 03 150
1 Brand1 403050 04 500
..
..
..
Can you address SQL statement to achieve this change?
Regards,
Luis

Nov 13 '05 #1
1 3300
SELECT Version, Product, Account, 01 As Month, Jan As Amount
FROM MyTable
UNION
SELECT Version, Product, Account, 02 As Month, Feb As Amount
FROM MyTable
UNION
SELECT Version, Product, Account, 03 As Month, Mar As Amount
FROM MyTable
UNION
....
UNION
SELECT Version, Product, Account, 12 As Month, Dec As Amount
FROM MyTable

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

<ca******@yahoo .com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,
I Have data stored with the following structure:
Version Product Account Jan Feb Mar Apr May ... Dec
1 Brand1 403050 100 200 150 500 400 100
Id'like to transform it in the following table:
Version Product Account Month Amount
1 Brand1 403050 01 100
1 Brand1 403050 02 200
1 Brand1 403050 03 150
1 Brand1 403050 04 500
.
.
.
Can you address SQL statement to achieve this change?
Regards,
Luis

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6424
by: jenny.rhodes | last post by:
Hello, Please can anyone guide me on how to transpose an access table where I have many records per id eg UserID Question Answer 1 1 a 1 2 d 1 3 c 1 4 d
1
2329
by: Jenny | last post by:
Hello, Please can anyone guide me on how to transpose an access table where I have many records per id eg UserID Question Answer 1 1 a 1 2 d
7
12053
by: sangeetha | last post by:
Hi, i need to transpose a nx1 matrix to 1xn matrix inorder to multiply with nxn matrix in c language ... can anyone help in this coding ..the nx1 matrix is pi the data type is double *pi..this is used through out the program ..now i need this transpose for further calculations.... Kindly help as soon as possible.....if this is not possible kindly suggest me something...
7
3594
by: Leszek Gruszka | last post by:
I wrote an aplication that write something into tableA in sql2000. I want to write the same, but transposed into tableB. Someone can help me? Any example? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
8
1916
by: Leszek Gruszka | last post by:
I wrote code, that fill TableA with records by executenonquery. But i want to have second TableB, that will be transposed TableA. My code: Public Sub SQL_Wpis() Dim sSQL As String sSQL = "SELECT * FROM KanaSecRep" Dim objConn As New SqlConnection(sConnection) Dim objDataAdapter As New SqlDataAdapter(sSQL, objConn) Dim objDS As New DataSet("KA_STAN")
3
3118
by: Gerard Brunick | last post by:
My way is ugly. These has to be a better way. Thanks, Gerard
4
2121
by: infiniti | last post by:
Hi, I am coming across problems in trying to EFFICIENTLY merge to XML files into one which involves transposing the rows into columns so that I can either generate a single flat xml file or store it in a flat table in the database. The 2 XML files which I have are: <xml> <keyword>
6
4961
by: JayDawg | last post by:
Excel has this cool little function where you can copy data, and then paste it transposed so that which runs across the rows now runs down a colum and visa versa. Is there a way in access to create a report that would transpose the data from what is logical. I have a query that has a field for the date (by month) and then additional fields (15 of them) by which I enter in data. So in the Table/Query it is formated such that when the...
4
4035
by: pc_whocares | last post by:
My forehead is flat from pounding. I am building a DLL in VS2005 C++ for use in another software development platform. I am required to pass my array data in/out of the function via a pointer, in this case, to double. The simplest way for me to transpose the array is via addressing its individual elements in the conventional form such as
5
12583
by: jenniferhelen | last post by:
I have been searching threads for a while and found the instructions listed below many times, however when I get to step 6 and select to save, I always receive the following error, "The information cannot be pasted because the copy area and the paste area are not the same size and shape". Does this function only work if the number or rows and number of columns are the same number? Does anyone have any suggestions for me? I greatly appreaciate...
0
8476
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8914
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7433
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6223
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4224
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.