Re: Re: Row Number
Joseph Charpak <[email protected]> Mon, 14 Jan 2013 16:34:32 -0500
| Newsgroups | gmane.comp.db.oracle.toad.free |
|---|---|
| Message-ID | <[email protected]> |
Careful while this works if you don't include an "order by " the minute you include an "order by" the results are inteterminate e.g. select col1, col2, col3, rownum from yourTableName order by col1 3 xxxxx xxxxxx 1 xxxxx xxxxxx 2 xxxxx xxxxxx select col1, col2, col3, rownum from yourTableName order by col2 2 xxxxx xxxxxx 1 xxxxx xxxxxx 3 xxxxx xxxxxx select col1, col2, col3, rownum from yourTableName order by col3 1xxxxx xxxxxx 2 xxxxx xxxxxx 3 xxxxx xxxxxx Hence what I said about being borderline useless. Rank() works as you expect it to every time. The problem was rank() didn't exist until Oracle 9 or so. On 01/14/2013 04:20 PM, joefootball_91 wrote: > > Thanks! > > --- In [email protected] <mailto:toad%40yahoogroups.com>, > "gene.l.bradley" wrote: > > > > add the column rownum. > > > > ex > > > > select col1, col2, col3, rownum > > from yourTableName > > > > > > On Mon, Jan 14, 2013 at 3:03 PM, joefootball_91 wrote: > > > > > ** > > > > > > > > > Is there a way to add a row number to a query? I want to use the row > > > number as a unique id field. Is there a function similar to the > > > ROW_NUMBER() that's available? > > > > > > I have a table named CUSTOMERS with fields titled FirstName and > LastName. > > > I want each row to have a unique number (the first row 1, the > second row 2, > > > third row 3, etc.) similar to the table below. > > > > > > ID FirstName LastName > > > 1 xxxxx xxxxxx > > > 2 xxxxx xxxxxx > > > 3 xxxxx xxxxxx > > > 4 xxxxx xxxxxx > > > N xxxxx xxxxxx > > > > > > Thanks, > > > > > > Joe > > > > > > > > > > > > > > > > > -- > > Gene L. Bradley Jr. > > Software Developer I > > Information Systems & Integration > > Jackson State University > > 1400 J R Lynch Street > > P.O. Box 17750 > > Jackson, MS 39217 > > > > ph 601.979.1042 > > fax 601.371.9146 > > email gbradley@... > > > >