In: Computer Science
Write an SQL statement to show which customers bought which items, and include any items that have not been sold. Include LastName, FirstName, InvoiceNumber, InvoiceDate,ItemNumber, ItemDescription, ArtistLastName, and ArtistFirstName. Use a join using JOIN ON syntax, and sort the results by ArtistLastName and ArtistFirstName in ascending order (Hint: you have to use a RIGHT JOIN on the last step).
I have assumed that "CustomerData" contains the
data related to
Customer i.e.
CustomerData(FirstName,LastName,InvoiceNumber,ItemNumber)
and "ArtistData" contains the data related to
Artist i.e.
ArtistData(ItemNumber,ItemDescription,ArtistLastName,ArtistFirstName)
NOTE: Please
update the table name if it is different.
SQL
QUERY
SELECT c.FirstName,c.LastName,c.InvoiceNumber,a.ItemNumber,
a.ItemDescription,a.ArtistLastName,a.ArtistFirstName
FROM CustomerData c
RIGHT JOIN
ArtistData a
ON a.ItemNumber = c.ItemNumber
ORDER BY a.ArtistFirstName ASC