What is the correct answer to this? SQL QUESTION Sales Data for All Customers and Products Write
Fantastic news! We've Found the answer you've been seeking!
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 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;
Related Book For
Data Modeling and Database Design
ISBN: 978-1285085258
2nd edition
Authors: Narayan S. Umanath, Richard W. Scammel
Posted Date: