Oracle, Inserting correlative numbers based on other fields
Sorry for my english:
My q开发者_如何转开发uery select date from mytable
returns something like this:
DATE
27/09/2011
27/09/2011
27/09/2011
27/09/2011
28/09/2011
28/09/2011
29/09/2011
29/09/2011
29/09/2011
I also need that my query returns a correlative based on each diferent date. something like...
DATE | CORRELATIVE
|
27/09/2011 | 1
27/09/2011 | 2
27/09/2011 | 3
27/09/2011 | 4
28/09/2011 | 1
28/09/2011 | 2
29/09/2011 | 1
29/09/2011 | 2
29/09/2011 | 3
I need help to get it, something like select date, any_way_to_get_it from mytable
thk!
Here's the function you should use.
SELECT date, ROW_NUMBER()
OVER (PARTITION BY date ORDER BY date) AS any_way_to_get_it
FROM mytable;
精彩评论