Untitled

 avatar
user_3268554
plain_text
a month ago
813 B
2
Indexable
Never
SELECT c.*, p.*
FROM ventas v
JOIN clientes c ON v.id_cliente = c.id
JOIN productos p ON v.id_producto = p.id;


SELECT DISTINCT c.id, c.nombre, c.apellido
FROM ventas v
JOIN clientes c ON v.id_cliente = c.id
WHERE YEAR(v.fecha_venta) > 2000;


SELECT v.id AS id_vendedor, v.nombre AS nombre_vendedor
FROM vendedores v
LEFT JOIN ventas ve ON v.id = ve.id_vendedor
WHERE ve.id_vendedor IS NULL;

SELECT p.id, p.descripcion
FROM productos p
LEFT JOIN ventas v ON p.id = v.id_producto
WHERE v.id_producto IS NULL;

SELECT c.nombre AS nombre_cliente, c.apellido AS apellido_cliente, v.nombre AS nombre_vendedor, v.apellido AS apellido_vendedor
FROM clientes c
JOIN ventas ve ON c.id = ve.id_cliente
JOIN vendedores v ON ve.id_vendedor = v.id
WHERE c.direccion = 'Cubas'
ORDER BY v.apellido;
Leave a Comment