| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Select Distinct (was top N or rewriting MAX)
Solomon.Yakobson_at_entex.com wrote:
>
> Yes, duplicates weren't mentioned explicitly. But they are real
> life and the original question is real life question.
> E.g. question how to select top 10 customers based on spent $
> amount already assumes possibility of duplicates (two or more
> customers spent same $ amount), etc.
>
OK try this then:
begin
declare
mycount number;
max_count number := 10;
ccur is
select customer_no
from customers
order by amout_spend desc;
begin
for crec in ccur loop
mycount := mycount + 1;
if mycount > max_count then
exit loop;
end if;
dbms_output.put_line(to_char(customer_number));
end loop;
Alan Wilson Help fight continental drift. ======================================================================Received on Wed Jan 22 1997 - 00:00:00 CST
![]() |
![]() |