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

Home -> Community -> Usenet -> c.d.o.tools -> SQL Query Help

SQL Query Help

From: Wallace Fukumae <fukumae_at_nosc.mil>
Date: 1997/11/24
Message-ID: <01bcf91c$6f7a0740$440637c6@honu>#1/1

Problem:
A tableT has two fields 'fieldA', 'fieldB'. fieldA is a character field but contains
only numbers for priorities. fieldB is a character field identifying the record.
I would like to generate a query which would return rownum,fieldA,fieldB from
tableT but ordered by fieldA. For example, I would like to return the top 500 records from tableT. However, as we know if you use the order by clause with rownum, rownum is based only off of the select, so rownum would be correct for the select but as soon as the sorting takes place with the order by clause rownum would be out of sync.

TABLE T:
fieldA number
fieldB varchar2(10)

SAMPLE DATA:

HONDA		44
TOYOTA	45
HYUNDAI	90
FORD		5
CHEVORLET	8

DESIRE:
1	FORD		5
2	CHEVORLET	8
3	HONDA		44
4	TOYOTA	45
5	HYUNDAI	90

Thanks, Wally Received on Mon Nov 24 1997 - 00:00:00 CST

Original text of this message

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