Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How Can I Select a Specific Number of Rows Using a Sorting Criterion?
Helge wrote:
> I'd like to do something like this:
>
> insert into temp_table_1 select id_number, criterion from source_view
> order by criterion ;
> insert into temp_table_2 select id_number, criterion from temp_table_2
> where rownum <= 5000 ;
>
> Of course, the order by clause isn't allowed in a subquery.
>
> Instead I've come up with a brute force method, which is to mark all
> rows that I want to include, count the marked rows, and if they aren't
> enough increase the selection criterion by one step and mark the rows
> again. Repeat until the count is large enough. It's not very elegant,
> but it's the only method I could think of.
>
> Does anyone else have a better way to do this?
What does a subquery have to do with anything you posted?
And does your Oracle installation have a version number?
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Wed Jun 21 2006 - 16:25:29 CDT