Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Sequential counter in SELECT statement

Sequential counter in SELECT statement

From: Stephen Miller <stepmil_at_ibm.net>
Date: 1997/03/15
Message-ID: <332B78CF.4D64@ibm.net>#1/1

I need to produce a report (using SQL*PLUS) which has a sequential counter defined as the first column of the report. This is easy enough to do using ROWNUM as the first column as long as the result is not sorted. Is it possible to produce this result in a sorted report?

Ex: SELECT sequential_counter_of_some_sort

             ,customer_id
             ,customer_name
         FROM customer_table
        WHERE region   = 'EAST'
     ORDER BY customer_id

;

The output should be like

ROWNUM CUSTOMER_ID CUSTOMER_NAME

------ ----------- -------------
     1     1000-01 Customer Name
     2     2010-99 Customer Name

.
.
12345 9999-87 Customer Name Environment is IBM AIX 3.2.5 ORACLE 7.0.16 SQL*PLUS 3.1

Thx,

Stephen Miller Received on Sat Mar 15 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US