You are on page 1of 2

1.- select c.nombre,v.nombres from cliente c,factura f, vendedor v where c.cedula=f.

cliente and
v.cedula=f.vendedor and v.nombres='henry';

2.- select v.oficina, v.nombres from vendedor v where v.oficina = (select sub.oficina from (select
v.oficina as oficina,sum(f.total) as total from factura f,vendedor v where f.vendedor = v.cedula group
by v.oficina) sub where sub.total = (select max(sub2.total) from (select v.oficina as oficina,sum(f.total)
as total from factura f,vendedor v where f.vendedor = v.cedula group by v.oficina) sub2) );

3.- select v.nombres from vendedor v where oficina = (select sub.oficina from (select v.oficina as
oficina,sum(f.total) as total from factura f,vendedor v where f.vendedor = v.cedula and
date_part('days',f.fecha)< 15 and date_part('month',f.fecha)=8 group by v.oficina) sub where sub.total =
(select max(sub2.total) from (select v.oficina as oficina,sum(f.total) as total from factura f,vendedor v
where f.vendedor = v.cedula and date_part('days',f.fecha)< 15 and date_part('month',f.fecha)=8 group
by v.oficina) sub2));

4.- select p.nombre, sub2.codigo from (select sub.producto as codigo from (select df.producto as
producto, sum(df.cantidad) as total from detalle_fact df group by df.producto) sub where sub.total < 2
group by sub.producto) sub2,producto p where sub2.codigo=p.nro_produc;

5.- select sub2.cedula,c.nombre from (select sub.cedula from (select f.cliente as cedula, sum(total) as
total from factura f where date_part('quarter',f.fecha)=3 and date_part('year',f.fecha)= 2014 group by
f.cliente) sub where sub.total > 2500) sub2, cliente c where c.cedula=sub2.cedula;

6.- select o.nombre from oficina o where o.numero = (select v.oficina from vendedor v where cedula =
(select vendedor from (select f.vendedor as vendedor, sum(f.total) as total_vendedor from factura f
group by f.vendedor) sub where sub.total_vendedor >= (select sum(f.total)*0.55 as total_general from
factura f)));

7.- select oficina from (select v.oficina as oficina, sum(f.total) as total1 from factura f, vendedor v
where f.vendedor = v.cedula group by v.oficina) sub where sub.total1 >=(select sum (f.total)*0.50 as
total from factura f, vendedor v, oficina o where o.numero = v.oficina and v.cedula=f.vendedor);

9.- select v.cedula,v.nombres from vendedor v, factura f where f.fecha=v.ingreso and
f.vendedor=v.cedula;

10.- select v.* from vendedor v,(select vend.vendedor from (select sub.vendedor, sum(f.total) as total_v
from (select vendedor.cedula as vendedor,jefe.cedula as jefe from vendedor as jefe inner join vendedor
on vendedor.jefe=jefe.cedula) sub, factura f where sub.vendedor = f.vendedor group by sub.vendedor)
vend, (select sub.jefe,sum(f.total) as total_j from (select vendedor.cedula as vendedor,jefe.cedula as
jefe from vendedor as jefe inner join vendedor on vendedor.jefe=jefe.cedula) sub, factura f where
sub.jefe = f.vendedor group by sub.jefe) jef where vend.total_v > jef.total_j) sub where v.cedula=
sub.vendedor;

You might also like