If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 Sql select with numberation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-11, 07:51
maggo119 maggo119 is offline
Registered User
 
Join Date: Aug 2011
Posts: 4
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.
Reply With Quote
  #2 (permalink)  
Old 08-16-11, 08:10
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #3 (permalink)  
Old 08-16-11, 09:28
maggo119 maggo119 is offline
Registered User
 
Join Date: Aug 2011
Posts: 4
Thanks, it worked with rank and row_number
Reply With Quote
Reply

Tags
numberation, sql select

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On