Home » SQL & PL/SQL » SQL & PL/SQL » Numbering on break
Numbering on break [message #448532] Wed, 24 March 2010 00:37 Go to next message
Messages: 1
Registered: March 2010
Junior Member
I have a query with output as:
CUST	          PROD
Customer1	Product1
Customer1	Product2
Customer1	Product3
Customer2	Product1
Customer2	Product2
Customer3	Product1
The output required is
Number    CUST	          PROD
   1    Customer1	Product1
        Customer1	Product2
        Customer1	Product3
   2    Customer4	Product1
        Customer4	Product2
   3    Customer5	Product1

For every change in customer i need to put a new serial number..

How can this be done..Please help

[EDITED by LF: applied [pre] tags]

[Updated on: Wed, 24 March 2010 02:53] by Moderator

Report message to a moderator

Re: Numbering on break [message #448534 is a reply to message #448532] Wed, 24 March 2010 00:40 Go to previous messageGo to next message
Michel Cadot
Messages: 63924
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.

Have a look at ROW_NUMBER, RANK and DENSE_RANK functions.

If you post a working Test case: create table and insert statements along with the result you want with these data then we will work with your table and data.

Tell me and I'll forget; show me and I may remember; involve me and I'll understand
Re: Numbering on break [message #448646 is a reply to message #448532] Wed, 24 March 2010 08:13 Go to previous message
Messages: 4621
Registered: February 2005
Location: East Coast USA
Senior Member
Where are customer 4 and 5 coming from?
Previous Topic: How to call
Next Topic: help on collections
Goto Forum:

Current Time: Wed Oct 26 07:10:33 CDT 2016

Total time taken to generate the page: 0.05081 seconds