how to do this GROUP BY in SQL*PLUS
Date: Wed, 27 May 1992 22:47:06 GMT
Message-ID: <fragante.707006826_at_chilko.ucs.ubc.ca>
How can I perform the following GROUP BY in SQL*PLUS:
For instance, I have a SALESMAN table with the following fields:
SALESMAN - name of SALESMAN selling tickets TICKET_NO - contains sequential numbers, just like with real tickets
What I would like to do is group by each SALESMAN with their corresponding
series of TICKET_NO. The result would be like this:
My initial query looked like this:
SELECT SALESMAN, MIN(TICKET_NO), MAX(TICKET_NO), COUNT(TICKET_NO)
FROM TICKETS
SALESMAN TICKET_NO_FROM TICKET_NO_TO COUNT
-------- --------------- ------------ -----
JOHN 1 50 50
76 100 25
RICK 51 75 25
176 200 25
TOM 151 175 25
WAYNE 76 150 75
GROUP
BY SALESMAN
I think the GROUP BY clause should be expanded so that it can detect a break in the sequential numbering of the tickets. HOW DO I DO THIS ???
If anyone has an alternative way around this GROUP BY, I'd be interested to try your method out.
Thanks. Received on Thu May 28 1992 - 00:47:06 CEST