Need help to build a query.

  • Dear All,

    Need help to build query ,Data in the below format

    Name Dept Punch Date Status

    Robin Purchase 4/3/14 18:00 Out

    Robin Purchase 4/3/14 17:57 In

    Robin Purchase 4/3/14 15:04 Out

    Robin Purchase 4/3/14 14:20 In

    Alex Accounts 4/3/14 14:09 Out

    Alex Accounts 4/3/14 14:07 In

    Alex Accounts 4/3/14 10:53 Out

    Alex Accounts 4/3/14 7:52 In

    I need the query which gives the output in the below Format

    Name Dept Punch Date Status

    Robin Purchase 4/3/14 18:00 Out

    4/3/14 17:57 In

    4/3/14 15:04 Out

    4/3/14 14:20 In

    Alex Accounts 4/3/14 14:09 Out

    4/3/14 14:07 In

    4/3/14 10:53 Out

    4/3/14 7:52 In

    Thanks and Regards

    Prakash

  • You cannot just have less columns on a row then on another row.

    Formatting output is better done with a front-end application, like SSRS.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Keon is right, sounds like you just want a simple SSRS report grouped by Name.

  • Dang, sorry spelled "Koen" wrong.

  • Michael_Garrison (4/10/2014)


    Dang, sorry spelled "Koen" wrong.

    No problem. 😉

    There is an "edit" button by the way. 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • select name,dept, punchdate ,status from Table_name

    where name='robin'

    select name,dept, punchdate ,status from Table_name

    where name='Alex'

  • manju00005 (6/5/2014)


    select name,dept, punchdate ,status from Table_name

    where name='robin'

    select name,dept, punchdate ,status from Table_name

    where name='Alex'

    The original question was about formatting, not about how to select the data.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 7 posts - 1 through 6 (of 6 total)

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