Querys Bd
SELECT * FROM customers WHERE country="france"
B)
SELECT employeeNumber,lastName,firstName,city FROM
employees INNER JOIN offices ON employees.officeCode=offices.officeCode
WHEREcity="san francisco"
ORDER BY lastName
c)
SELECT customerNumber,customerName,firstName,lastName FROM customers
INNER JOIN employees ONcustomers.salesRepEmployeeNumber=employees.employeeNumber
WHERE firstName="pamela" AND lastName="castillo"
D)
SELECT customerNumber,customerName,phone,addressLine1,country,state,city,salesRepEmployeeNumber FROM customers WHERE salesRepEmployeeNumberIS NULL
ORDER BY country
E)
SELECT products.productCode,orderNumber,productName,quantityOrdered,priceEach,(priceEach*quantityOrdered) AS subtotal FROM products
INNER JOIN orderdetails ONproducts.productCode=orderdetails.productCode
WHERE orderNumber=10173
GROUP BY subtotal
F)
SELECT customerName,SUM(quantityOrdered*priceEach) AS total, STATUS FROM customers
INNER JOINorders ON customers.customerNumber=orders.customerNumber
INNER JOIN orderdetails ON orders.orderNumber=orderdetails.orderNumber
WHERE STATUS!="cancelled"
GROUP BY orderdetails.orderNumber DESC LIMIT5
G)
SELECT orders.customerNumber,SUM(quantityOrdered*priceEach) AS ordenado,
(SELECT SUM(amount) AS total FROM payments WHERE payments.customerNumber = orders.customerNumber GROUP BYcustomerNumber) AS pagado,
(SUM(quantityOrdered*priceEach) - (SELECT SUM(amount) AS total FROM payments WHERE payments.customerNumber = orders.customerNumber GROUP BY customerNumber))
AS saldo FROM ordersINNER JOIN orderdetails ON orderdetails.`orderNumber` = orders.`orderNumber`
WHERE orders.`status` != 'cancelled'
GROUP BY orders.customerNumber
ORDER BY saldo DESC
H)
SELECTcustomerNumber,customerName,phone,salesRepEmployeeNumber FROM customers WHERE salesRepEmployeeNumber IS NULL
I)
(SELECT offices.`officeCode`,SUM(quantityOrdered*priceEach) AS ventas FROM offices...
Regístrate para leer el documento completo.