PC Review


Reply
Thread Tools Rate Thread

Country Data Merge

 
 
chisholm.alexander@gmail.com
Guest
Posts: n/a
 
      17th Oct 2006
Hi Everyong-

I've got a database with many tables, each containing different
economic data for many countries. I want to be able to have all the
data in one table.

The problem is that some tables have different countries.

Example:
Table 1:
Italy 454
Germany 342
France 342

Table 2:
Italy 34
Ireland 12
France 23
Spain 23

>From this I would like a Table 3 similar to this:


Table 3:
Italy 454 34
Germany 342 -
France 343 23
Spain - 23


Does anyone have any advice???

Thanks

Alex

 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      17th Oct 2006
On 16 Oct 2006 20:23:03 -0700, (E-Mail Removed) wrote:

>Hi Everyong-
>
>I've got a database with many tables, each containing different
>economic data for many countries. I want to be able to have all the
>data in one table.
>
>The problem is that some tables have different countries.
>
>Example:
>Table 1:
>Italy 454
>Germany 342
>France 342
>
>Table 2:
>Italy 34
>Ireland 12
>France 23
>Spain 23


If you have FIELDS named Italy, Germany, and so on, that's a real
problem. And if each Table contains a different type of economic data,
that's an even worse problem! Storing data in fieldnames and
tablenames is simply bad design, and not how relational databases are
designed to work.

>>From this I would like a Table 3 similar to this:

>
>Table 3:
>Italy 454 34
>Germany 342 -
>France 343 23
>Spain - 23


How about, instead, a properly normalized table with fields Country,
Datatype, Amount? I don't know what the numbers in Table1 and Table2
represent, but a normalized structure would have (e.g.)

Country Datatype Amount
Italy Table1Stuff 454
Italy Table2Stuff 34
Germany Table1Stuff 342
France Table2Stuff 23
France Table1stuff 342
Spain Table2Stuff 23

and so on. You can, given this structure, create a Crosstab Query
which will be exactly your desired output, using Country as the Row
Header and Datatype as the Column Header.

To migrate the data from your current spreadsheets into the normalized
table, use an Append query for each one:

INSERT INTO newtable ([Country], [Datatype], [Amount]
SELECT [Country], "Table1Stuff" AS Datatype, [Valuefield] AS Amount
FROM Table1;

with similar queries for your other tables.

John W. Vinson[MVP]
 
Reply With Quote
 
Joseph Meehan
Guest
Posts: n/a
 
      17th Oct 2006
John Vinson wrote:
> On 16 Oct 2006 20:23:03 -0700, (E-Mail Removed) wrote:
>
>> Hi Everyong-
>>
>> I've got a database with many tables, each containing different
>> economic data for many countries. I want to be able to have all the
>> data in one table.
>>
>> The problem is that some tables have different countries.
>>
>> Example:
>> Table 1:
>> Italy 454
>> Germany 342
>> France 342
>>
>> Table 2:
>> Italy 34
>> Ireland 12
>> France 23
>> Spain 23

>
> If you have FIELDS named Italy, Germany, and so on, that's a real
> problem. And if each Table contains a different type of economic data,
> that's an even worse problem! Storing data in fieldnames and
> tablenames is simply bad design, and not how relational databases are
> designed to work.
>
>>> From this I would like a Table 3 similar to this:

>>
>> Table 3:
>> Italy 454 34
>> Germany 342 -
>> France 343 23
>> Spain - 23

>
> How about, instead, a properly normalized table with fields Country,
> Datatype, Amount? I don't know what the numbers in Table1 and Table2
> represent, but a normalized structure would have (e.g.)
>
> Country Datatype Amount
> Italy Table1Stuff 454
> Italy Table2Stuff 34
> Germany Table1Stuff 342
> France Table2Stuff 23
> France Table1stuff 342
> Spain Table2Stuff 23
>
> and so on. You can, given this structure, create a Crosstab Query
> which will be exactly your desired output, using Country as the Row
> Header and Datatype as the Column Header.
>
> To migrate the data from your current spreadsheets into the normalized
> table, use an Append query for each one:
>
> INSERT INTO newtable ([Country], [Datatype], [Amount]
> SELECT [Country], "Table1Stuff" AS Datatype, [Valuefield] AS Amount
> FROM Table1;
>
> with similar queries for your other tables.
>
> John W. Vinson[MVP]


Follow John's advice. Normalize now and do it right or mess around over
and over until you find out that normalizing is really easier and faster
than trying to make a database work like a spreadsheet. I know it seems
like the hard complex way, but Access likes it that way and can do all kinds
of things if you work with it. :-)

--
Joseph Meehan

Dia duit


 
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
Mail Merge hiding Country on IF Statement! Potsy Microsoft Word Document Management 2 28th Jun 2007 03:20 PM
When I try to do a mail merge, the zip code is where the country =?Utf-8?B?TWFybGVuZQ==?= Microsoft Outlook Contacts 1 8th Oct 2005 06:25 PM
country setting doesn't match actual default country =?Utf-8?B?YXhlbGxvZGk=?= Windows XP Help 5 14th Nov 2004 09:50 AM
Country/Region in maiing adddress on mail merge Bill Microsoft Outlook Contacts 1 13th May 2004 09:38 PM
Matching Address Country with Phone Number Country Outlook 2003 Alexander Schek Microsoft Outlook 0 29th Oct 2003 04:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:19 PM.