Crea el siguiente procedimiento:
Código SQL
[-]create procedure MejoresClientes(Rango integer)
returns (IDCliente int, Nombre varchar(60), DNI varchar(20), CntVentas int) as
begin
for select C.IDCLIENTE, NOMBRE, DNI, count(IDVENTA)
from (CLIENTE C inner join VENTA V on C.IDCLIENTE = V.IDCLIENTE)
group by NOMBRE, DNI, C.IDCLIENTE
having count(IDVENTA) > 0
order by 4 desc
into :IDCliente, :Nombre, :CNI, CntVentas do
begin
suspend;
Rango = Rango - 1;
if (Rango = 0) then exit;
end
end
Y lo llamas así:
Código SQL
[-]select * from MejoresClientes(10)
Saludos y nos platicas como te fue...
Gerardo Suárez Trejo. (Y si te sacas diez de calificación en la tesis: 5 para tí y 5 para mi
)