473,406 Members | 2,847 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,406 software developers and data experts.

Sql, Transform/pivot

nullgumby
Working in Access 2003.

I'm trying to write a query and have been looking at the TRANSFORM and PIVOT keywords, but can't seem to get them connected right.

My table is like this:
Expand|Select|Wrap|Line Numbers
  1. PrimaryKeyID    MyType    MyValue
  2. 1        Fruit    Apple
  3. 1        Veggie    Tomato
  4. 1        Meat    Chicken
  5. 2        Fruit    Orange
  6. 2        Veggie    Potato    
  7. 3        Fruit    Banana
I want the results to look like this:
Expand|Select|Wrap|Line Numbers
  1. PrimaryKeyID    Fruit    Veggie    Meat
  2. 1        Apple    Tomato    Chicken
  3. 2        Orange    Potato    NULL
  4. 3        Banana    NULL    NULL
Can anyone help me out with this? Thanks.
Nov 9 '06 #1
2 8538
NeoPa
32,556 Expert Mod 16PB
I suggest cheating.
Do it as a preliminary attempt by using the wizard to help, then see the resulting SQL and see how it does what you want.
Very important technique.
I learnt most of my VBA by getting Excel to 'Record' VBA macros for me then doctoring the results.
Nov 9 '06 #2
I suggest cheating.
That's what I did! :D ...this seems to work:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM First(MyValue) AS FirstMyValue
  2. SELECT PrimaryKeyID
  3. FROM MyTable
  4. GROUP BY PrimaryKeyID
  5. PIVOT MyType;
Nov 9 '06 #3

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

Similar topics

5
by: Charles Law | last post by:
I have posted this on a couple of Access and SQL Server newsgroups, but with no answer yet. There seems to be very little activity on the ones I have looked at, so I thought I would post here as...
1
by: carrionk | last post by:
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 ...
2
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines...
3
by: gapletona | last post by:
I have a table that I need to import into access. The table is monthly data where the month is the column header. I need to transform that data so that location code, month and number are the...
9
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury...
11
by: KevinM | last post by:
Hi I have a database storing trip details. There's a parent table which stores the basic trip information and a child table that stores the countries to be visited information. The query I have at...
2
by: Davidsm | last post by:
Hi I am having the following problem I a running a query off a table. I am using the following sql code TRANSFORM Sum(.loanamount/1000000) AS SumOfloanamount SELECT .Region FROM GROUP BY...
1
by: sunitapd | last post by:
Plz if ne1 knows how to convert rows into columns ie to use Pivot tell me.I m using the DBArtisan tool for accessing the Sybase server.
42
by: dugong | last post by:
Here is my query. TRANSFORM Count(t_date.ftime) AS Sumftime SELECT t_date.gh FROM t_date GROUP BY t_date.gh PIVOT t_date.fdate; What i'm doing is count the number of clocking per points number....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.