Home » SQL & PL/SQL » SQL & PL/SQL » Resetting running total (9i)
Resetting running total [message #293048] Thu, 10 January 2008 13:40 Go to next message
dukeslater
Messages: 11
Registered: November 2007
Location: Oklahoma USA
Junior Member
My previous post concerned writing an employee hierarchy to a text file, and with help I've got it working fine.

However, there is an additional requirement that was not supplied until now - each record needs a record number, and that number needs to reset upon each change of employee:

Emp.     Dept.     Record #
1         100         1
1         200         2
1         300         3
2         100         1
2         200         2
3         200         1
3         300         2
3         400         3

etc.


The records are written to the text file from a temp table, so I can update a column with the record number. Offhand, though, I have no idea how I would do that. A cursor would probably work, but first I thought I'd see if anyone had a better, easier way.

Thank you.
Re: Resetting running total [message #293054 is a reply to message #293048] Thu, 10 January 2008 14:00 Go to previous messageGo to next message
Michel Cadot
Messages: 65154
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
ROW_NUMBER

Regards
Michel
Re: Resetting running total [message #293055 is a reply to message #293054] Thu, 10 January 2008 14:06 Go to previous messageGo to next message
dukeslater
Messages: 11
Registered: November 2007
Location: Oklahoma USA
Junior Member
Perfect. Can you tell I'm usually a SQL Server guy?

Thank you.
Re: Resetting running total [message #293121 is a reply to message #293048] Thu, 10 January 2008 23:49 Go to previous message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Welcome to Exciting world of Oracle Cool

Thumbs Up
Rajuvan.
Previous Topic: adding zeros to the left of a number in the number column
Next Topic: query help
Goto Forum:
  


Current Time: Wed Aug 23 10:29:37 CDT 2017

Total time taken to generate the page: 0.09757 seconds