1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

to join tables based on columns

Discussion in 'SQL - Questions and Answers' started by prathi, Aug 21, 2009.

  1. prathi New Member

    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.

Share This Page