Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record counter with reset 1

Status
Not open for further replies.

nagornyi

MIS
Nov 19, 2003
882
US
I have two fields in a table, with multiple values of field2 for each field1 value. Like this:
Code:
field1  field2
======  ======
  A       232
  B       116
  A       456
  A       565
  B       968
I need a SQL that would include a column counting field2 entries for each value of field1, and resetting for each field1 value. So the result would be:
Code:
field1  field2  counter
======  ======  =======
  A       232       1
  A       456       2
  A       565       3
  B       116       1
  B       968       2
 

Use the DENSE_RANK() analytic function. [3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top