Monday, February 20, 2012

Join problem

hi

I have got two tables and each table has about 8000000 rows..

the format of the tables is as follows....

Table 1

Comnpany_name Id Year Volume_jan Volume_feb....... Volume_dec

ABC 1 2000 12 34 44

ABC 2 2000 222 50 44

.........................................................................................................................

Table 2

Comnpany_name Id Year Volume_jan Volume_feb....... Volume_dec

VVV 1 2001 125 12 44

VVV 2 2001 22 500 441

.........................................................................................................................

Now i need to make a report out of these tables which should be of the following format

Comnpany_name Id Year Volume_jan Volume_feb....... Volume_dec

ABC 1 2000 12 34 44

ABC 2 2000 222 50 44

.VVV 1 2001 125 12 44

VVV 2 2001 22 500 441

........................................................................................................................

how shall i do this because when i try to run the report in business intelligance , it takes forever to process and doesnt even produce any result

I dont have any indexes on my table as i dont have any primary key..

Pls help me nad suggest as to how should i manage such huge tables?

Select * From Table1

UNION

Select * From Table2

This assumes that the fields in both tables are in the same order and type compatible.

|||

so u mean to say that if i do this query the data from table 2 will appear to be appended to table1?

because i dont want the repeated column names

for ex company name should appeat only once

|||

Yes, data from table two will be appended. The names for the columns will be taken from the select statement for table 1. The names of the columns from table 2 are ignored, the only requirement is for the column types to be compatible. The first column specified in the select statement for the second table will be matched to the first columns in the select statement for table1.

No comments:

Post a Comment