cross tab query

  • Hi All,

    I have a below table structure

    cpr attendance_Date attendance_Time Trans_Type

    123 20-Aug-13 8:8:10 I

    123 20-Aug-13 6:10:10 O

    123 21-Aug-13 8:10:10 I

    123 21-Aug-13 7:8:10 O

    123 22-Aug-13 5:5:10 O

    expected output

    cpr attendance_date trans_type

    123 20-Aug-13 In Out

    123 21-Aug-13 In Out

    123 22-Aug-13 Null Out

    any help is highly appreciated.

    regards

  • Something like this perhaps:

    select

    cpr,

    attendance_date,

    trans_in = max(case when trans_type='I' then 'In' end),

    trans_out = max(case when trans_type='O' then 'Out' end),

    from Table

    group by cpr, attendance_date

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

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