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
SmrithiNair
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: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
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.


Regards
Michel
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
joy_division
Messages: 4963
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: Sun Feb 16 00:33:52 CST 2025