473,503 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query to transpose rows to columns via Primary Key

Hi All,

This is similar to a question I asked earlier however this is following
a more "correct" way of doing things. I have normalised and summarised
an Exchange addressbook (a few thousand enteries) into a table storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another table
containing Dealer information held against DealerID (where DealerID is
the unique Primary Key).

I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all emails
relating to that dealer from the tblDealerEmails HOWEVER I can only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 || DlrEmail
n

There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or form).

Does anyone have any idea as to how I would go about this? (Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up to
5).

Please note I'm NOT after a philosophical debate about the "correct"
ways to query/store/normalize data as I know this is an unorthodox way
to present data but such is life! Thanks in advance for any help!

-Mal W

Dec 8 '06 #1
8 6050
have you tried using a Crosstab query? if you've never created one, suggest
you start by using the Crosstab Query Wizard; then you can tweak it if
needed.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi All,

This is similar to a question I asked earlier however this is following
a more "correct" way of doing things. I have normalised and summarised
an Exchange addressbook (a few thousand enteries) into a table storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another table
containing Dealer information held against DealerID (where DealerID is
the unique Primary Key).

I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all emails
relating to that dealer from the tblDealerEmails HOWEVER I can only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 || DlrEmail
n

There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or form).

Does anyone have any idea as to how I would go about this? (Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up to
5).

Please note I'm NOT after a philosophical debate about the "correct"
ways to query/store/normalize data as I know this is an unorthodox way
to present data but such is life! Thanks in advance for any help!

-Mal W

Dec 8 '06 #2
"tina" <no****@address.comwrote in
news:1i*********************@bgtnsc05-news.ops.worldnet.att.net:
have you tried using a Crosstab query? if you've never created
one, suggest you start by using the Crosstab Query Wizard;
then you can tweak it if needed.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
>Hi All,

This is similar to a question I asked earlier however this is
following a more "correct" way of doing things. I have
normalised and summarised an Exchange addressbook (a few
thousand enteries) into a table storing DealerID and
DealerEmail (where the DealerEmail is the Primary Key as it's
unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake)
another table containing Dealer information held against
DealerID (where DealerID is the unique Primary Key).

I need to be able to have a query that lists each DealerID,
their relevant Dealer Information from the tblDealerInfo
table AND all emails relating to that dealer from the
tblDealerEmails HOWEVER I can only have 1 row per dealer.
What I want the query to display is (again simplified for
examples sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2
|| DlrEmail n

There are specific reasons why I need the query to output in
this format (and it has to do with interfacing correctly with
a legacy system so I can NOT change the input format in any
way shape or form).

Does anyone have any idea as to how I would go about this?
(Keeping in mind some dealers may have 1 DlrEmail, others may
have anything up to 5).

Please note I'm NOT after a philosophical debate about the
"correct" ways to query/store/normalize data as I know this
is an unorthodox way to present data but such is life! Thanks
in advance for any help!

-Mal W
A crosstab query will not work in this instance.

>


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 8 '06 #3
Hi there,

I'm not sure how this would work with a crosstab query, my
understanding would be a Crosstab would try to make each email address
a Column Title and then try to do some sort of count (or some other
arithmetic calculation) on how many email addresses were grouped to
that DealerID.

I don't often use Crosstab queries so there maybe a large gap in my
understanding of their functionality, so if there is a way to do this
via Crosstab please explain! My understanding...I don't think there is.

Thanks!

tina wrote:
have you tried using a Crosstab query? if you've never created one, suggest
you start by using the Crosstab Query Wizard; then you can tweak it if
needed.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi All,

This is similar to a question I asked earlier however this is following
a more "correct" way of doing things. I have normalised and summarised
an Exchange addressbook (a few thousand enteries) into a table storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another table
containing Dealer information held against DealerID (where DealerID is
the unique Primary Key).

I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all emails
relating to that dealer from the tblDealerEmails HOWEVER I can only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 || DlrEmail
n

There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or form).

Does anyone have any idea as to how I would go about this? (Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up to
5).

Please note I'm NOT after a philosophical debate about the "correct"
ways to query/store/normalize data as I know this is an unorthodox way
to present data but such is life! Thanks in advance for any help!

-Mal W
Dec 8 '06 #4
"m.wanstall" <m.********@gmail.comwrote in
news:11**********************@80g2000cwy.googlegro ups.com:
Hi All,

I need to be able to have a query that lists each DealerID,
their relevant Dealer Information from the tblDealerInfo table
AND all emails relating to that dealer from the
tblDealerEmails HOWEVER I can only have 1 row per dealer. What
I want the query to display is (again simplified for examples
sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 ||
DlrEmail n
Does anyone have any idea as to how I would go about this?
(Keeping in mind some dealers may have 1 DlrEmail, others may
have anything up to 5).
Use a function to concatenate the column into a single
expression.

The most versatile one I've found is fConcatChild()
Google that word and copy the function text from the browser to
a new module. www.mvps.org/access/modules/mdl0004.htm is the
first site and it's a good one.

Use it as instructed.


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 8 '06 #5
you and Bob are right, of course; i seem to have a mental block about
crosstab queries. <g>
but fortunately, somebody else has come up with a solution that may meet
your needs. see MVP Duane Hookom's solution at
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='Generic%20Function%2 0To%20Concatenate%20Child%20Records'.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
Hi there,

I'm not sure how this would work with a crosstab query, my
understanding would be a Crosstab would try to make each email address
a Column Title and then try to do some sort of count (or some other
arithmetic calculation) on how many email addresses were grouped to
that DealerID.

I don't often use Crosstab queries so there maybe a large gap in my
understanding of their functionality, so if there is a way to do this
via Crosstab please explain! My understanding...I don't think there is.

Thanks!

tina wrote:
have you tried using a Crosstab query? if you've never created one,
suggest
you start by using the Crosstab Query Wizard; then you can tweak it if
needed.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi All,
>
This is similar to a question I asked earlier however this is
following
a more "correct" way of doing things. I have normalised and summarised
an Exchange addressbook (a few thousand enteries) into a table storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another table
containing Dealer information held against DealerID (where DealerID is
the unique Primary Key).
>
I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all
emails
relating to that dealer from the tblDealerEmails HOWEVER I can only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:
>
DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 ||
DlrEmail
n
>
There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or form).
>
Does anyone have any idea as to how I would go about this? (Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up to
5).
>
Please note I'm NOT after a philosophical debate about the "correct"
ways to query/store/normalize data as I know this is an unorthodox way
to present data but such is life! Thanks in advance for any help!
>
-Mal W
>

Dec 8 '06 #6
I would set up a query to apply a custom sequence number to each email,
dealerId, seq, email
where seq = 1,2,3 etc for each dealer.

search groups for ways to do that, using DMAX or a query.
then an update/append query on the lines:

email1 : iif(seq = 1, [newemail],[email1])
email2: iif(seq=2,[newemail],[email2])
.............................
or you could go the VBA route.
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi All,

This is similar to a question I asked earlier however this is following
a more "correct" way of doing things. I have normalised and summarised
an Exchange addressbook (a few thousand enteries) into a table storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another table
containing Dealer information held against DealerID (where DealerID is
the unique Primary Key).

I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all emails
relating to that dealer from the tblDealerEmails HOWEVER I can only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 || DlrEmail
n

There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or form).

Does anyone have any idea as to how I would go about this? (Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up to
5).

Please note I'm NOT after a philosophical debate about the "correct"
ways to query/store/normalize data as I know this is an unorthodox way
to present data but such is life! Thanks in advance for any help!

-Mal W


Dec 8 '06 #7
Thanks to all, those concat functions have hit the nail on the head and
saved me from reinventing the wheel!

Much appreciated!

tina wrote:
you and Bob are right, of course; i seem to have a mental block about
crosstab queries. <g>
but fortunately, somebody else has come up with a solution that may meet
your needs. see MVP Duane Hookom's solution at
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='Generic%20Function%2 0To%20Concatenate%20Child%20Records'.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
Hi there,

I'm not sure how this would work with a crosstab query, my
understanding would be a Crosstab would try to make each email address
a Column Title and then try to do some sort of count (or some other
arithmetic calculation) on how many email addresses were grouped to
that DealerID.

I don't often use Crosstab queries so there maybe a large gap in my
understanding of their functionality, so if there is a way to do this
via Crosstab please explain! My understanding...I don't think there is.

Thanks!

tina wrote:
have you tried using a Crosstab query? if you've never created one,
suggest
you start by using the Crosstab Query Wizard; then you can tweak it if
needed.
>
hth
>
>
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi All,

This is similar to a question I asked earlier however this is
following
a more "correct" way of doing things. I have normalised and summarised
an Exchange addressbook (a few thousand enteries) into a table storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another table
containing Dealer information held against DealerID (where DealerID is
the unique Primary Key).

I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all
emails
relating to that dealer from the tblDealerEmails HOWEVER I can only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:

DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 ||
DlrEmail
n

There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or form).

Does anyone have any idea as to how I would go about this? (Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up to
5).

Please note I'm NOT after a philosophical debate about the "correct"
ways to query/store/normalize data as I know this is an unorthodox way
to present data but such is life! Thanks in advance for any help!

-Mal W
Dec 10 '06 #8
yep, Duane is da man! :)
"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
Thanks to all, those concat functions have hit the nail on the head and
saved me from reinventing the wheel!

Much appreciated!

tina wrote:
you and Bob are right, of course; i seem to have a mental block about
crosstab queries. <g>
but fortunately, somebody else has come up with a solution that may meet
your needs. see MVP Duane Hookom's solution at
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='Generic%20Function%2 0To%20Concatenate%20Child%20Records'.

hth
"m.wanstall" <m.********@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
Hi there,
>
I'm not sure how this would work with a crosstab query, my
understanding would be a Crosstab would try to make each email address
a Column Title and then try to do some sort of count (or some other
arithmetic calculation) on how many email addresses were grouped to
that DealerID.
>
I don't often use Crosstab queries so there maybe a large gap in my
understanding of their functionality, so if there is a way to do this
via Crosstab please explain! My understanding...I don't think there
is.
>
Thanks!
>
tina wrote:
have you tried using a Crosstab query? if you've never created one,
suggest
you start by using the Crosstab Query Wizard; then you can tweak it
if
needed.

hth


"m.wanstall" <m.********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi All,
>
This is similar to a question I asked earlier however this is
following
a more "correct" way of doing things. I have normalised and
summarised
an Exchange addressbook (a few thousand enteries) into a table
storing
DealerID and DealerEmail (where the DealerEmail is the Primary Key
as
it's unique). The thing to keep in mind is that Dealers can have
multiple Emails. I have (simplified for examples sake) another
table
containing Dealer information held against DealerID (where
DealerID is
the unique Primary Key).
>
I need to be able to have a query that lists each DealerID, their
relevant Dealer Information from the tblDealerInfo table AND all
emails
relating to that dealer from the tblDealerEmails HOWEVER I can
only
have 1 row per dealer. What I want the query to display is (again
simplified for examples sake) as follows:
>
DealerID || DlrName || DlrAddress || DlrEmail1 || DlrEmail2 ||
DlrEmail
n
>
There are specific reasons why I need the query to output in this
format (and it has to do with interfacing correctly with a legacy
system so I can NOT change the input format in any way shape or
form).
>
Does anyone have any idea as to how I would go about this?
(Keeping in
mind some dealers may have 1 DlrEmail, others may have anything up
to
5).
>
Please note I'm NOT after a philosophical debate about the
"correct"
ways to query/store/normalize data as I know this is an unorthodox
way
to present data but such is life! Thanks in advance for any help!
>
-Mal W
>
>

Dec 11 '06 #9

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

Similar topics

7
10789
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
4
2847
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
1
18418
by: Chris Smith | last post by:
Experience Posters, Sorry if this is not the right group to post this question. He is my issue; Is there a way without the use of 3rd party controls, to transpose the rows of a datatable to...
7
3586
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...
6
4813
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
1
350
by: Radu | last post by:
Hi. I have a table with the following *COLUMNS*: PIN# # of weeks when Overtime 8 Overtime Week 1 Overtime Week 2 Overtime Week 3 .. ..
2
17627
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How can I run this query against a table in my Access database? I don't know hwo to use it in C#. In VB I would use .Recordset = "some sql statement". How do I do this in C#? //I get a vlaue...
2
3911
by: erbrose | last post by:
Hello All! Hoping some folks could help me optimize and or choose the best route to do this process. First off, here is what I am trying to achieve. I have a (fairly large) table of ~34million rows...
12
19804
by: jenniferhelen | last post by:
I am working with a query that has 6 columns and 101 rows; I would like to transpose the rows and columns. I have tried using a crosstab query but Access limits the row "fields" to 3 and this was...
0
7198
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
7072
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...
1
6979
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...
0
5570
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
4666
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...
0
3160
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...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.