PC Review


Reply
Thread Tools Rate Thread

Creating multiple records from a single record

 
 
kidkosmo
Guest
Posts: n/a
 
      9th Jan 2010
Hi, Gang,

I'm a bit perplexed with how I can perform this task. I have a set of
data that is arranged such as this:

Function e_p_date1 e_p_date2 e_p_date3
Training1 1/1/2010 1/2/2010 1/3/2010
Training2 1/4/2010 [null] [null]

I want to turn that into something more like below in order to add
into my crosstab query to calculate the number of events per function
(currently the crosstab is only calculating one training).

Function e_p_date
Training1 1/1/2010
Training1 1/2/2010
Training1 1/3/2010
Training2 1/4/2010

Any help would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Arvin Meyer [MVP]
Guest
Posts: n/a
 
      9th Jan 2010
You can do it with a series of append queries.

INSERT INTO tblMyTable( e_p_date)
SELECT e_p_date3
FROM tblMyTable
WHERE e_p_date3 Is Not Null);
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"kidkosmo" <(E-Mail Removed)> wrote in message
news:47a509be-4275-43d2-b91a-(E-Mail Removed)...
> Hi, Gang,
>
> I'm a bit perplexed with how I can perform this task. I have a set of
> data that is arranged such as this:
>
> Function e_p_date1 e_p_date2 e_p_date3
> Training1 1/1/2010 1/2/2010 1/3/2010
> Training2 1/4/2010 [null] [null]
>
> I want to turn that into something more like below in order to add
> into my crosstab query to calculate the number of events per function
> (currently the crosstab is only calculating one training).
>
> Function e_p_date
> Training1 1/1/2010
> Training1 1/2/2010
> Training1 1/3/2010
> Training2 1/4/2010
>
> Any help would be greatly appreciated.



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      9th Jan 2010
On Fri, 8 Jan 2010 18:21:15 -0800 (PST), kidkosmo <(E-Mail Removed)> wrote:

>Hi, Gang,
>
>I'm a bit perplexed with how I can perform this task. I have a set of
>data that is arranged such as this:
>
>Function e_p_date1 e_p_date2 e_p_date3
>Training1 1/1/2010 1/2/2010 1/3/2010
>Training2 1/4/2010 [null] [null]
>
>I want to turn that into something more like below in order to add
>into my crosstab query to calculate the number of events per function
>(currently the crosstab is only calculating one training).
>
>Function e_p_date
>Training1 1/1/2010
>Training1 1/2/2010
>Training1 1/3/2010
>Training2 1/4/2010
>
>Any help would be greatly appreciated.


A "Normalizing Union" query is the ticket here. You need to go into the SQL
window to build it, the query grid isn't up to the task!

SELECT [Function], [e_p_date1] AS [e_p_date]
FROM yourtable
WHERE [e_p_date1] IS NOT NULL
UNION ALL
SELECT [Function], [e_p_date2]
FROM yourtable
WHERE [e_p_date2] IS NOT NULL
UNION ALL
SELECT [Function], [e_p_date3]
FROM yourtable
WHERE [e_p_date3] IS NOT NULL;

This is in fact a more properly normalized structure for your table than what
you currently have.
--

John W. Vinson [MVP]
 
Reply With Quote
 
kidkosmo
Guest
Posts: n/a
 
      11th Jan 2010
On Jan 8, 7:44*pm, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com>
wrote:
> On Fri, 8 Jan 2010 18:21:15 -0800 (PST), kidkosmo <kidkos...@yahoo.com> wrote:
> >Hi, Gang,

>
> >I'm a bit perplexed with how I can perform this task. *I have a set of
> >data that is arranged such as this:

>
> >Function * * e_p_date1 * * *e_p_date2 * * e_p_date3
> >Training1 * * *1/1/2010 * * * * 1/2/2010 * * * 1/3/2010
> >Training2 * * *1/4/2010 * * * * [null] * * * * ** [null]

>
> >I want to turn that into something more like below in order to add
> >into my crosstab query to calculate the number of events per function
> >(currently the crosstab is only calculating one training).

>
> >Function * * e_p_date
> >Training1 * * 1/1/2010
> >Training1 * * 1/2/2010
> >Training1 * * 1/3/2010
> >Training2 * * 1/4/2010

>
> >Any help would be greatly appreciated.

>
> A "Normalizing Union" query is the ticket here. You need to go into the SQL
> window to build it, the query grid isn't up to the task!
>
> SELECT [Function], [e_p_date1] AS [e_p_date]
> FROM yourtable
> WHERE [e_p_date1] IS NOT NULL
> UNION ALL
> SELECT [Function], [e_p_date2]
> FROM yourtable
> WHERE [e_p_date2] IS NOT NULL
> UNION ALL
> SELECT [Function], [e_p_date3]
> FROM yourtable
> WHERE [e_p_date3] IS NOT NULL;
>
> This is in fact a more properly normalized structure for your table than what
> you currently have.
> --
>
> * * * * * * *John W. Vinson [MVP]- Hide quoted text -
>
> - Show quoted text -


The union query works GREAT! However, I am now having an issue with
duplicate records. In the example I provided, the e_p_dates are
different dates staff performs a follow up phone call; therefore, the
next time I import the data and parse them into different rows with
the union query, I can duplicate previous records. Any ideas on a
quick and dirty way I can enumerate the duplicate records and only
keep one of them?

Thanks!
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      11th Jan 2010
On Mon, 11 Jan 2010 08:12:00 -0800 (PST), kidkosmo <(E-Mail Removed)>
wrote:

>The union query works GREAT! However, I am now having an issue with
>duplicate records. In the example I provided, the e_p_dates are
>different dates staff performs a follow up phone call; therefore, the
>next time I import the data and parse them into different rows with
>the union query, I can duplicate previous records. Any ideas on a
>quick and dirty way I can enumerate the duplicate records and only
>keep one of them?


If you change each instance of UNION ALL to just UNION Access will dedup the
data for you.

However, your present data structure is *wrong* and is the source of your
difficulties! Properly normalizing your table to be tall-thin rather than
wide-flat will go a long way to make your task easier.
--

John W. Vinson [MVP]
 
Reply With Quote
 
kidkosmo
Guest
Posts: n/a
 
      11th Jan 2010
On Jan 11, 10:31*am, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Mon, 11 Jan 2010 08:12:00 -0800 (PST), kidkosmo <kidkos...@yahoo.com>
> wrote:
>
> >The union query works GREAT! *However, I am now having an issue with
> >duplicate records. *In the example I provided, the e_p_dates are
> >different dates staff performs a follow up phone call; therefore, the
> >next time I import the data and parse them into different rows with
> >the union query, I can duplicate previous records. *Any ideas on a
> >quick and dirty way I can enumerate the duplicate records and only
> >keep one of them?

>
> If you change each instance of UNION ALL to just UNION Access will dedup the
> data for you.
>
> However, your present data structure is *wrong* and is the source of your
> difficulties! Properly normalizing your table to be tall-thin rather than
> wide-flat will go a long way to make your task easier.
> --
>
> * * * * * * *John W. Vinson [MVP]


I agree the present data structure is wrong; unfortunately, that data
is being provided from an outside Oracle source to which I cannot
affect. I'll drop the ALL and see where that gets me.

Thanks for the assist!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Records into Single Record Jake Microsoft Access 3 29th Oct 2008 11:59 AM
to make a single row record become multiple row records =?Utf-8?B?QXNrRXhjZWw=?= Microsoft Excel Worksheet Functions 0 24th Feb 2006 09:46 AM
Generating multiple records from a single record =?Utf-8?B?c2Ftd2FyZGlsbA==?= Microsoft Access Queries 3 31st Oct 2005 05:47 PM
Creating a single record from multiple records with a unique key Marc via AccessMonster.com Microsoft Access Forms 1 3rd Jun 2005 11:03 PM
Multiple Records Into A Single Record... aljordan Microsoft Excel Misc 1 19th Aug 2004 09:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:21 AM.