Home » SQL & PL/SQL » SQL & PL/SQL » Rownum Within Group By
Rownum Within Group By [message #405575] Thu, 28 May 2009 07:38 Go to next message
fearthegrimp
Messages: 6
Registered: March 2009
Junior Member
Hi SQL boffins! I'm trying give a count and a number for each record within each group of a group by function but am struggling! Any ideas? Thanks y'all!

Eg

COL A COL B
10000 X
10000 Y
10000 Z
10001 X
10002 X
10002 Y
10003 X
10004 Y

I want my results to look like:

COL A COL B COL C
10000 X 1
10000 Y 2
10000 Z 3

10001 X 1

10002 X 1
10002 Y 2

10003 X 1
10003 Y 2
Re: Rownum Within Group By [message #405578 is a reply to message #405575] Thu, 28 May 2009 07:42 Go to previous messageGo to next message
bonker
Messages: 402
Registered: July 2005
Senior Member
search for row_number() analytical function Oracle documentation.

[Updated on: Thu, 28 May 2009 07:42]

Report message to a moderator

Re: Rownum Within Group By [message #405579 is a reply to message #405575] Thu, 28 May 2009 07:42 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
That would be the analytical row_number function you are looking for.

Or the analytical form of count
Re: Rownum Within Group By [message #405581 is a reply to message #405575] Thu, 28 May 2009 07:47 Go to previous message
fearthegrimp
Messages: 6
Registered: March 2009
Junior Member
Thank you good people!
Previous Topic: Do I need temporary table?
Next Topic: Retrieving alpha numeric data
Goto Forum:
  


Current Time: Sat Dec 10 11:13:18 CST 2016

Total time taken to generate the page: 0.08538 seconds