Question: What is the correct answer to this? SQL QUESTION Sales Data for All Customers and Products Write a query that will return sales details of

What is the correct answer to this?

SQL QUESTION

Sales Data for All Customers and Products

Write a query that will return sales details of all customers and products. The query should return all customersmer id, product id and invoice item id.


SELECT COALESCE(c.customer_name, 'N/A') AS customer_name,       COALESCE(p.product_name, 'N/A') AS product_name,       COALESCE(i.quantity, 0) AS quantityFROM customers cCROSS JOIN products pLEFT JOIN invoices inv ON c.customer_id = inv.customer_idLEFT JOIN invoice_items i ON inv.invoice_id = i.invoice_id AND p.product_id = i.product_idORDER BY c.customer_id, p.product_id, i.invoice_item_id;



Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To help you understand the SQL query that returns sales details for all customers and products Ill break it down and slightly correct it to ensure its ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!