Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2011
    Posts
    4

    Unanswered: DB2 Sql select with numberation

    Hi,

    I try to make a selection with dynamic numberation.

    My table looks like this:

    Name Street
    ==== ====
    Mark Street1
    Mark Street2
    Steve Street3
    Gena Street4
    Gena Street5

    The result should look like this:

    Name Nr Street
    ==== == ====
    Mark 1 Street1
    Mark 2 Street2
    Steve 1 Street3
    Gena 1 Street4
    Gena 2 Street5

    I hope someone has an idea how to solve this,
    cheers.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Have a look at the RANK() and/or ROW_NUMBER() functions. If you use a partition by "Name", you should get what you want.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Aug 2011
    Posts
    4
    Thanks, it worked with rank and row_number

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •