put 2 lines into 1 column

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Toralf =?utf-8?q?F=C3=B6rster?=

    put 2 lines into 1 column

    IHello,

    I've a table like this (location withprobably more than i ip address) :

    NAME IP_ADDRESS
    host1 1.1.x
    host1 1.2.x
    host2 2.1.x
    host2 2.2.x
    host3 3.x
    host4 4.x

    and try to get this output (but only with db2, not with awk, sed or sth
    similar nice UNIX tool) :

    host1 1.1.x 1.2.x
    host2 2.1.x 2.2.x
    host3 3.x
    host4 4.x

    I' am really struggling but didn't found a solution yesterday evening
    .... :-(

    --
    Toralf Förster
    pgp key 0x7DB69DA3


  • Serge Rielau

    #2
    Re: put 2 lines into 1 column

    Toralf Förster wrote:
    IHello,
    >
    I've a table like this (location withprobably more than i ip address) :
    >
    NAME IP_ADDRESS
    host1 1.1.x
    host1 1.2.x
    host2 2.1.x
    host2 2.2.x
    host3 3.x
    host4 4.x
    >
    and try to get this output (but only with db2, not with awk, sed or sth
    similar nice UNIX tool) :
    >
    host1 1.1.x 1.2.x
    host2 2.1.x 2.2.x
    host3 3.x
    host4 4.x
    >
    I' am really struggling but didn't found a solution yesterday evening
    ... :-(
    >
    Download my "SQL on Fire" slides from the web (google). There is a PIVOT
    and an UNPIVOT example.

    Cheers
    Serge


    --
    Serge Rielau
    DB2 Solutions Development
    IBM Toronto Lab

    Comment

    • Toralf =?utf-8?q?F=C3=B6rster?=

      #3
      Re: put 2 lines into 1 column

      jefftyzzer wrote:
      On Apr 10, 1:07 am, Toralf Förster <toralf.foers.. .@gmx.dewrote:
      Toralf:
      >
      I adapted the following SQL from Anthony Molinaro's _SQL Cookbook_.
      See if it helps you. Incidentally, I can't say enough good things
      about Serge's "SQL on Fire" presentations--you really should get them
      (go here: http://www.iiug.org/waiug/present/Fo...orum2006.html).
      >
      Regards,
      >
      --Jeff
      Thanks Jeff, I'use that method.

      --
      Toralf Förster
      pgp key 0x7DB69DA3


      Comment

      Working...