Está en la página 1de 3

1. select a.nombre from producto a inner join detalle b ON ( a.

id_producto =
b.id_producto ) where b.id_factura = "12345";

2. select a.nombre from producto a inner join detalle b ON ( a.id_producto =


b.id_producto ) inner join factura c
ON ( b.id_factura = c.id_factura ) where c.fecha between '2017-01-01' AND
'2017-01-31';

3. select count(a.num_pago) from modo_pago a inner join factura b ON ( a.num_pago =


b.num_pago ) where a.nombre = 'CREDITO';

4. select nombre from cliente where month(fecha_nacimiento) = 9;

5. select a.nombre from producto a inner join detalle b ON ( a.id_producto =


b.id_producto ) where b.id_factura is NULL;

6. select ( b.nombre, sum(b.cantidad)) from detalle a inner join producto b ON


( a.id_producto = b.id_producto )
group by b.nombre
HAVING
sum(a.cantidad) = (select max(sum(a.cantidad))) from detalle group by
id_producto);

7. select avg(a.cantidad) from detalle a inner join factura b ON (a.num_factura =


b.id_factura) inner join producto c ON (a.id_prodcuto = c.id_producto)
where c.nombre = "Tampones Drácula";

8. select avg(a.precio) from detalle a inner join factura b ON (a.num_factura =


b.id_factura) inner join producto c ON (a.id_prodcuto = c.id_producto)
where c.nombre = "Tampones Drácula";

9. select (a.nombre, sum(c.cantidad)) from categoria a inner join producto b ON


(a.id_categoria = b.id_categoria) inner join detalle c
ON (b.id_producto = c.id_detalle) group by a.id_categoria;

10. select ( b.nombre, avg(a.cantidad)) from detalle a inner join producto b ON


( a.id_producto = b.id_producto )
group by b.nombre
HAVING
avg(a.cantidad) < (select max(avg(a.cantidad))) from detalle group by
id_producto);

11. select (b.nombre, avg(a.cantidad)) from detalle a inner join producto b ON


( a.id_producto = b.id_producto )
group by b.nombre
HAVING
avg(a.cantidad) > (select max(avg(a.cantidad))) from detalle group by
id_producto);

12. select (b.nombre, avg(a.precio)) from detalle a inner join producto b ON


( a.id_producto = b.id_producto )
group by b.nombre
HAVING
avg(a.precio) < (select max(avg(a.cantidad))) from detalle group by
id_producto);

13. select (b.nombre, avg(a.precio)) from detalle a inner join producto b ON


( a.id_producto = b.id_producto )
HAVING
avg(a.precio) > (select max(avg(a.cantidad))) from detalle group by
id_producto)
group by b.nombre;

14. select count(a.num_pago) from modo_pago a inner join factura b ON (a.num_pago =


b.num_pago) where a.nombre = 'tarjeta de crédito'
AND b.fecha between '2019-03-01' AND '2019-03-31';

15. select (b.nombre, sum(a.precio)) from detalle a inner join factura c ON


(a.id_factura = c.num_factura) inner join cliente b ON ( b.id_cliente =
c.id_cliente)
group by b.nombre
HAVING
SUM(a.precio) = (select max(sum(a.precio))) from detalle group by
b.id_nombre);

16. select (a.nombre) from cliente a left join factura b ON (a.id_cliente =


b.id_cliente) where b.id_cliente is NULL;

17. select (a.num_factura) from factura a left join detalle b ON (a.num_factura =


b.id_factura) where b.id_factura is NULL;

18. select (b.num_detalle) from factura a right join detalle b ON (a.num_factura =


b.id_factura) where a.num_factura is NULL;

19. select (a.nombre, sum(c.cantidad)) FROM cliente a INNER JOIN factura b ON


(a.id_cliente = b.id_cliente) INNER JOIN detalle c
ON (b.num_factura = c.id_factura) INNER JOIN producto d ON (c.id_producto =
d.id_producto) INNER JOIN categoria e ON (d.id_categoria = e.id_categoria)
group by a.nombre
HAVING
sum(c.cantidad) = (select max(sum(c.cantidad))) from detalle where e.nombre =
'LACTEOS' group by id_producto);

20. select a.nombre FROM producto a WHERE a.nombre LIKE 'A%';

21. select a.nombre FROM producto a WHERE a.nombre LIKE '%A';

22. select a.nombre FROM producto a WHERE a.nombre LIKE '%Z%';

23. select avg(2020 – (year(a.fecha_nacimiento))) from cliente a INNER JOIN facture


b ON (a.id_cliente = b.id_cliente);

24. select avg(2020 – (year(a.fecha_nacimiento))) from cliente a LEFT JOIN factura


b ON (a.id_cliente = b.id_cliente) where b.num_factura IS NULL;

25. select (a.nombre, count(a.nombre)) from modo_pago a inner join factura b ON


(a.num_pago = b.num_pago) inner join cliente c ON (b.id_cliente = c.id_cliente)
group by a.nombre
HAVING
count(a.nombre) = (select max(count(a.nombre)) from factura group by
num_factura);

26. select (a.nombre, count(a.nombre)) from modo_pago a inner join factura b ON


(a.num_pago = b.num_pago) inner join cliente c ON (b.id_cliente = c.id_cliente)
inner join detalle d ON (b.num_factura = d.id_factura)
group by a.nombre
HAVING
count(a.nombre) = (select max(count(a.nombre)) from factura group by
d.cantidad);

27. select (a.nombre, count(a.nombre)) from modo_pago a inner join factura b ON


(a.num_pago = b.num_pago) inner join cliente c ON (b.id_cliente = c.id_cliente)
inner join detalle d ON (b.num_factura = d.id_factura)
group by a.nombre
HAVING
count(a.nombre) = (select max(count(a.nombre)) from factura group by
d.precio);

28. select (a.id_factura, avg(count(a.id_producto))) from detalle a group by


id_factura;

29. select (a.nombre, e.nombre, c.precio) from cliente a inner join factura b ON
(a.id_cliente = b.id_cliente) inner join detalle c
ON (b.num_factura = c.id_factura) inner join producto d ON (c.id_producto =
d.id_producto) inner join categoria e
ON (d.id_categoria = b.id_categoria);

30. select (a.nombre, b.precio) from producto a inner join detalle b ON


(a.id_producto = b.id_producto);

También podría gustarte