473,395 Members | 1,678 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,395 software developers and data experts.

Help in transposing data itno columns

Hoping someone can help me. I have 2 Access tables with a one to many relationship. the 1 side table holds the billing information, the many table side holds the billing id and modifier#. Now I need to transpose the data into: billing id, modifier1, and modifier 2.

If I do a crosstab query I get different modifiers as column headings but I only want the 2 columns.

for example:

billing id modifier 1 modifier2

1100 50 49
1101 60 50
1102 47
1103 50

Can someone point me in the way of achieving this. Thanks!
Dec 20 '07 #1
11 2159
Rabbit
12,516 Expert Mod 8TB
Use a subquery to "rank" by your modifier and then do your crosstab on the rank.
Dec 20 '07 #2
I don't know what you mean "to do a rank in a subquery". How would I do that?


Hoping someone can help me. I have 2 Access tables with a one to many relationship. the 1 side table holds the billing information, the many table side holds the billing id and modifier#. Now I need to transpose the data into: billing id, modifier1, and modifier 2.

If I do a crosstab query I get different modifiers as column headings but I only want the 2 columns.

for example:

billing id modifier 1 modifier2

1100 50 49
1101 60 50
1102 47
1103 50

Can someone point me in the way of achieving this. Thanks!
Dec 21 '07 #3
jaxjagfan
254 Expert 100+
Does each billingid only have 2 possible modifiers? If not then your crosstab is going to display the maximum number of modifiers. If billingid (X) has had 10 modifiers and no others have had more than 10 then the crosstab will display 10 columns.
Dec 21 '07 #4
Rabbit
12,516 Expert Mod 8TB
Well, I'm guessing your data is like this:
Expand|Select|Wrap|Line Numbers
  1. Field1   Field2
  2. 1100     50
  3. 1100     49
  4. 1101     60
  5. 1101     50
  6. 1102     47
  7. 1103     50
  8.  
This:
Expand|Select|Wrap|Line Numbers
  1. SELECT Field1, Field2, 
  2.        (SELECT Count(*)
  3.        FROM Table1
  4.        WHERE Field1 = x.Field1 AND Field2 <= x.Field2) AS Rank
  5. FROM Table1 AS x;
  6.  
Will give you:
Expand|Select|Wrap|Line Numbers
  1. Field1   Field2   Rank
  2. 1100     50       2
  3. 1100     49       1
  4. 1101     60       2
  5. 1101     50       1
  6. 1102     47       1
  7. 1103     50       1
  8.  
Then you crosstab on the Rank field.
Dec 21 '07 #5
Thank you so much for your help. I get the query to work but now when I try to do the crosstab query on the query I get a message that microsoft jet does not recognize x.billingid. I'm at a lost.

Well, I'm guessing your data is like this:
Expand|Select|Wrap|Line Numbers
  1. Field1   Field2
  2. 1100     50
  3. 1100     49
  4. 1101     60
  5. 1101     50
  6. 1102     47
  7. 1103     50
  8.  
This:
Expand|Select|Wrap|Line Numbers
  1. SELECT Field1, Field2, 
  2.        (SELECT Count(*)
  3.        FROM Table1
  4.        WHERE Field1 = x.Field1 AND Field2 <= x.Field2) AS Rank
  5. FROM Table1 AS x;
  6.  
Will give you:
Expand|Select|Wrap|Line Numbers
  1. Field1   Field2   Rank
  2. 1100     50       2
  3. 1100     49       1
  4. 1101     60       2
  5. 1101     50       1
  6. 1102     47       1
  7. 1103     50       1
  8.  
Then you crosstab on the Rank field.
Jan 3 '08 #6
Rabbit
12,516 Expert Mod 8TB
You shouldn't be using x.billingid in your crosstab unless your query is actually named x. Don't confuse the alias with the name of your query.
Jan 3 '08 #7
I'm using the query to build the crosstab. Here is what I've done.
I have the query "qryBillingDetailRank" which uses the code you provided me:

[code]
SELECT [billingid], [modifier], (SELECT Count(*) FROM tblBillingDetail WHERE billingid = billingdetailrank.billingid AND modifier <= billingdetailrank.modifier) AS Rank
FROM tblBillingDetail AS billingdetailrank; [code]

then I build a crosstab on using the qryBillingDetailRank.

[code]
TRANSFORM First(qryBillingDetailRank.modifier) AS FirstOfmodifier
SELECT qryBillingDetailRank.billingid, First(qryBillingDetailRank.modifier) AS [Total Of modifier]
FROM qryBillingDetailRank
GROUP BY qryBillingDetailRank.billingid
PIVOT qryBillingDetailRank.Rank; [code]

When I run it, I get the message "the microsoft jet database engine does not recognize "billingdetailrank.billingid" as a valid field name or expression.

billingdetailrank.billingid is in the first query.

Is my problem that I have to make a table and run the crosstab on the table and not the query?

I truly appreciate your help. HZ




You shouldn't be using x.billingid in your crosstab unless your query is actually named x. Don't confuse the alias with the name of your query.
Jan 4 '08 #8
Rabbit
12,516 Expert Mod 8TB
I understand now, it does look like you have to create a table first before using the crosstab. I'll test it out and get back to you.
Jan 4 '08 #9
Rabbit
12,516 Expert Mod 8TB
Yep, looks like you'll have to create a table from the ranking query first before crosstabbing.
Jan 4 '08 #10
Thank you so much for your patience and help
Jan 4 '08 #11
Rabbit
12,516 Expert Mod 8TB
Not a problem, good luck.
Jan 5 '08 #12

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

Similar topics

2
by: Fabio | last post by:
Hello, is there any quite easy solution for the problem of transposing the rows into the columns? I have the following table with some data in it: dealer date 09.00 10.00 11.00 ...
8
by: Leszek Gruszka | last post by:
Hello! I need to transpose some columns into rows and rows into columns. I know, tha i can do it by cursor, but i don't know how make it... I read a lot about it, but still don't understand......
0
by: Christoph Lutz | last post by:
Hi, I would like to transpose a table in mysql. I have looked on the web for a while but nothing seems to fit the bill, so I just want to clarify if I have to write some php or if I can use a...
4
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...
11
by: Bryan Kyle | last post by:
Hi All, I'm fairly new to C# and Generics and I'm wondering if anyone has some suggestions for me. I'm trying to implement a simple DAO framework using generics to keep my code as clean as I...
9
by: Classic-Car-World Ltd | last post by:
Hi, I have some data in a table in columns which I need to convert into rows. This is specification data for some tools etc. The data is currently in the following format: Product No, order,...
1
by: TimHop12 | last post by:
Lets consider the following query: Select Col1, Col2 from Table1 where Colx = 'A5100650867' This gives result as: Col1 Col2 E-mail Address xyz@GMAIL.com...
10
by: eskelies | last post by:
I have a sanitized database which I have attached, and for the most part transposes the data to my liking. There is however a few issues that I would like to fix, but cannot determine the problem in...
3
by: =?Utf-8?B?Q2Fpcm4=?= | last post by:
I have some XML data which I wish to relate to existing classes, but data does not map exactly so serialsation will not work, the other consideration is that some of the XML data will need...
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...
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...

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.