SQL help

  • I have the following data in a table1

    record_id, colname, beforeval , afterval

    1,col2,'JOHN' null

    1 col2, null, 'JOE'

    2, col2 'JANE', null

    2 , col2 null, 'JANIE'

    I want the result as follows in one row

    1, col2, JOHN, JOE

    2, col2, JANE, JANIE

    Any help would be greatly appreciated.

  • Why does record_id 2 ends up with value 'col1' for colname?

    Have you tried using MAX() and MIN() to aggregate rows?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (7/28/2016)


    Why does record_id 2 ends up with value 'col1' for colname?

    Have you tried using MAX() and MIN() to aggregate rows?

    Sorry typo

    It's col2 for all.

  • So, are you good now?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • @luis,

    The OP should be good enough now.

  • Luis Cazares (7/28/2016)


    So, are you good now?

    Yes, thanks for checking. When you mentioned Max it pointed me to the right direction.

    Thanks

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

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