Loading ...
Sorry, an error occurred while loading the content.
 

RE: [SQLQueriesNoCode] Making 12 Records Into One Record Of Anoth er Table

Expand Messages
  • Terri Morton
    First we need to write a query which will get the data you are looking for. I don t understand your fields in the Salary table, but something along these lines
    Message 1 of 1 , May 30, 2003
      First we need to write a query which will get the data you are looking for.
      I don't understand your fields in the Salary table, but something along
      these lines should work for you:

      SELECT
      T0.empNo
      ISNULL(T1.salary,0) AS JanSalary
      ISNULL(T2.Salary,0) AS FebSalary
      ISNULL(T3.salary,0) AS MarSalary
      ...
      ISNULL(T12.salary,0) AS DecSalary
      FROM
      Salary T0
      LEFT OUTER JOIN
      Salary T1 ON T0.empNo = T1.empNo AND T1.month = 'January'
      LEFT OUTER JOIN
      Salary T2 ON T0.empNo = T2.empNo AND T2.month = 'February'
      LEFT OUTER JOIN
      Salary T3 ON T0.empNo = T3.empNo AND T3.month = 'March'
      ...
      LEFT OUTER JOIN
      Salary T12 ON T0.empNo = T12.empNo AND T12.month = 'December'

      Terri




      -----Original Message-----
      From: umesh Baboo [mailto:cm_umesh@...]
      Sent: Friday, May 30, 2003 1:09 AM


      Hi all

      I have a table By Name Salary it contains all the
      empno,Jan-Dec Salary(Basic,Da,pf)
      It means for one year 12 record of each employee.
      I have a one more table(Anul_Salary) that contains 12
      columns (eno,enam,janColumn To DecColumn).
      Now i like to store all the 12 records of each emp
      information in Anul_Salary,each 12 records of Salary
      Table should be one record of Anul_Salary.
      I need a solution for this problumn with in a one sql
      Query i like to finsh all the concept is it posible,
      using front end (looping) its posible.But it will be
      length the process and it will take huge time. I like
      save the time and trap that looping from front end
    Your message has been successfully submitted and would be delivered to recipients shortly.