Help required in SQL Statement

  • I need a SQL Statement to return data in required format ...

    Sample Data

    emp_noemp_nameemp_statusemp_time 
    0001JohnPresent09:00 AM
    0002SmithLeave-
    0003ClarkLate11:15 AM
    0001JohnPresent09:00 AM
    0002SmithLate11:55 AM
    0003ClarkLeave-

    Required Results

    emp_noemp_nameemp_statusemp_time emp_statusemp_time
    0001JohnPresent09:00 AMPresent09:00 AM
    0002SmithLeave-Late11:55 AM
    0003ClarkLate11:15 AMLeave-

    Thanks in advance and it will provide me great help.

  • How to decide which record becomes the first set of (emp_status, emp_time) and which bocomes the 2nd?

    Which field(s) makes the unique key of sample data?

  • Sorry there was one additional field that i missed ... i.e. emp_date

    here we go again

    Sample Data

    emp_noemp_nameemp_statusemp_time emp_date

    0001

    John

    Present

    09:00 AM

    21-05-07

    0002

    Smith

    Leave

    -

    21-05-07

    0003

    Clark

    Late

    11:15 AM

    21-05-07

    0001

    John

    Present

    09:00 AM

    22-05-07

    0002

    Smith

    Late

    11:55 AM

    22-05-07

    0003

    Clark

    Leave

    -

    22-05-07

     

    Required Results

    emp_noemp_nameemp_statusemp_time emp_dateemp_statusemp_timeemp_date

    0001

    John

    Present

    09:00 AM

    21-05-07

    Present

    09:00 AM

    22-05-07

    0002

    Smith

    Leave

    -

    21-05-07

    Late

    11:55 AM

    22-05-07

    0003

    Clark

    Late

    11:15 AM

    21-05-07

    Leave

    -

    22-05-07

  • Can it be assumed that [emp_no + emp_date] will make all records unique?

  • Basiclly as shown in sample data that there are fields like emp_no, emp_name  I actually wants emp_no, emp_name, emp_date fields grouped togather and emp_status, emp_time should repeate until emp_date is not over.

    It is not necessary that emp_date column should be displayed.

    Please see the blow grid it may clear some more concept.

     21-05-0722-05-07
    emp_noemp_nameemp_statusemp_time emp_statusemp_time
    0001JohnPresent09:00 AMPresent09:00 AM
    0002SmithLeave-Late11:55 AM
    0003ClarkLate11:15 AMLeave-

     

    I know that results can't display as above but it is just to give you some more understanding.

    Thank in adv.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply