to join two tables which has records in columns format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prathi
    New Member
    • Aug 2009
    • 2

    to join two tables which has records in columns format

    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........... ............... ............... ....103col 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.
  • jsmithstl
    New Member
    • Jun 2007
    • 14

    #2
    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?

    Comment

    • prathi
      New Member
      • Aug 2009
      • 2

      #3
      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............. ..............2 00


      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

      Comment

      • OraMaster
        New Member
        • Aug 2009
        • 135

        #4
        Originally posted by prathi
        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.
        Last edited by debasisdas; Aug 22 '09, 09:41 AM. Reason: removed unnecessary quote.

        Comment

        • amitpatel66
          Recognized Expert Top Contributor
          • Mar 2007
          • 2358

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

          Comment

          Working...