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
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
Get step-by-step solutions from verified subject matter experts
