Write a query that will return sales details of all customers and products. The query should return all customers, even customers without invoices and also all products, even those products that were not sold. Print "N/A" for a null customer or product name, and 0 for a null quantity. For each row return customer name, product name, and the quantity of the product sold. Order the result ascending by customer id, product id and invoice item id.



Answer :

The query code for that requirement will be written use SQL.

The query code is,

SELECT IFNULL(customer_name, "N/A") customer_name,

IFNULL(product_name, "N/A") product_name, IFNULL(quantity, 0) quantity

FROM ((customer LEFT OUTER JOIN invoice ON customer.id = invoice.customer_id)

     LEFT OUTER JOIN invoice_item ON invoice_item.invoice_id = invoice.id)

LEFT OUTER JOIN product ON invoice_item.product_id = product.id

ORDER BY customer.id, product.id,invoice_item.id;

SELECT statement is for select the data.

IFNULL function is to return specific value for NULL expression, or return the expression if the expression is not NULL.

FROM statement is to specify the selected data.

LEFT OUTER JOIN statement to combine the data include unmatched row.

ORDER BY statement is to arrange the data in specific order.

You question is incomplete, but most probably your full question was

(images attached)

Learn more about query here:

brainly.com/question/27851066

#SPJ4

View image rk16
View image rk16
View image rk16
View image rk16

Other Questions