Increment sequnce no based on calender date. [message #596552] |
Tue, 24 September 2013 13:07 |
|
nisaros
Messages: 1 Registered: September 2013 Location: Chennai
|
Junior Member |
|
|
Hi There,
I have a scenario wherin i need to be increasing the sequence no by 1 for every calender date.
For example lets say if i receive 5 dumps of data for 24/09/2013 it should be as below. For next day the 25th the sequence no should again begin with 1.
24/09/2013 1
24/09/2013 2
24/09/2013 3
24/09/2013 4
24/09/2013 5
25/09/2013 1
Please help
[Updated on: Tue, 24 September 2013 13:07] Report message to a moderator
|
|
|
|
|
Re: Increment sequnce no based on calender date. [message #596566 is a reply to message #596552] |
Tue, 24 September 2013 14:39 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
nisaros wrote on Tue, 24 September 2013 23:37
I have a scenario wherin i need to be increasing the sequence no by 1 for every calender date.
For example lets say if i receive 5 dumps of data for 24/09/2013 it should be as below. For next day the 25th the sequence no should again begin with 1.
24/09/2013 1
24/09/2013 2
24/09/2013 3
24/09/2013 4
24/09/2013 5
25/09/2013 1
You can do this using Analytic function. Use DENSE RANK, then PARTITION BY the date column and ORDER BY a proper column. For each date group you will have a rank as a pseudo column. Use the pseudo column as sequence.
Dense Rank
Regards,
Lalit
|
|
|
|
|
Re: Increment sequnce no based on calender date. [message #596575 is a reply to message #596569] |
Tue, 24 September 2013 17:05 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Hi nisaros, welcome to OraFAQ.
I think Lalit was right to direct you to Analytic Functions. He was probably thinking of the RANK() function rather than DENSE_RANK(), although I would have suggested ROW_NUMBER() as it is more descriptive of what you are trying to achieve.
On the odd chance that you came to an Oracle forum to ask a non-Oracle related question, I apologise for cluttering the forum with yet another response that doesn't answer your question.
Ross Leishman
|
|
|