Connecting Tech Pros Worldwide Forums | Help | Site Map

to join two tables which has records in columns format

Newbie
 
Join Date: Aug 2009
Posts: 2
#1: Aug 21 '09
Hi,

I have two tables which is having records in columns i.e.,suppose in first table is having 104 columns as 104 weeks and second row has salaries for that 104 weeks.i.e each column has the total salary for 1 week.

then the second table will also have 104 columns but in this table the 104th column will have the salary of that week i.e if the first table was generated on say 1st jan, and the second table is generated on 8th jan then the secound table will have the total salary for that week.

And the 1st column in first table will not be there in second table i.e, the second column of first table will be the first column in second table and so on.

first table(1st jan)
1col 2col 3col 4col.............................................1 03col 104col
100 95 120 85 210 85

second table(8th jan)
1col 2col 3col 4col.............................................. 103col 104col
95 120 100 200 110 130


but in the above example the data in the 3col of second table has been changed,it should be 85 but it is 100.
i need to write a query which will find out the changed data comparing the two tables which has the data in column format.

the result i need should be in this fromat.
date week salary
1st jan X week 85
8th jan X week 100

i.e, for the same week the data has changed.

please do the needful.thanks in advance.

Newbie
 
Join Date: Jun 2007
Posts: 12
#2: Aug 21 '09

re: to join two tables which has records in columns format


I'm not sure I understand. It sounds like each column represents a week and there are 104 weeks but week 1 in table 2 compares to week 2 in table 1.

Can you do a describe of each table and post them?

What is it you are trying to accomplish? It sounds like a different table design might help. Are you able to change the design or do you have no choice but to use this design?
Newbie
 
Join Date: Aug 2009
Posts: 2
#3: Aug 21 '09

re: to join two tables which has records in columns format


I have two tables for example say
Table A was generated on 1st jan
it has 104 columns i.e the data for 104 weeks each column is for 1 week and the total salary for 1week in 1 column.

A(1st jan)
week col1 col2 col3 col4..........................col104
salary 120 95 100 85...........................200


Table B has the same columns upto 104 weeks but as it is generated on
8th jan the Table B data will start from second week of Table A.But the data in Table B has changed i.e the col4 in Table A and col3 in Table B data should be same but it is different.

B(8th jan)

week col1 col2 col3 col4..........................col104
salary 95 100 125 150...........................200

I need to write a query to find where the data has changed.
the result should come as follows

date week salary
1st jan X week 85
8th jan X week 125
OraMaster's Avatar
Member
 
Join Date: Aug 2009
Location: Pune, India
Posts: 76
#4: Aug 21 '09

re: to join two tables which has records in columns format


Quote:

Originally Posted by prathi View Post

Hi,

I have two tables which is having records in columns
..............

Try to normalize your database tables. As I am not sure but thinking that you might have not understood your requirement properly otherwise you did not use such kind of database table structure. Post tables DDL anyways and brief ur requirement again.
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#5: Aug 24 '09

re: to join two tables which has records in columns format


Can you please post the table structure and its data that was generated on 01jan and 08 jan for reference of our expert?
Reply