In: Computer Science
5. Write the SQL query that accomplishes the task in the ZAGI Retail Company Sales Department Database:
5.1.3. Display the CustomerName and CustomerZip for all customers, sort alphabetically by CustomerName.
5.1.4. Display the RegionID of regions where we have stores (use only table STORES and do not display the same information more than once).
5.1.5 Display all the information for all stores whose ReigionID value is C
5.1.8 Display the ProductID, ProductName, ProductPrice, and VendorName for all products. Sort the results by ProductID.
5.1.10 Display the ProductID, ProductName, and ProductPrice for products in the category whose CategoryName value is Camping. Sort the results by ProductID.
5.1.11 Display the ProductID, ProductName, and ProductPrice for products that were sold in the zip code 60600. Sort the results by ProductID
5.1.3. Display the CustomerName and CustomerZip for all customers, sort alphabetically by CustomerName.
Ans:-
SELECT CustomerName,CustomerZip FROM customers ORDER BY CustomerName ASC;
5.1.4. Display the RegionID of regions where we have stores (use only table STORES and do not display the same information more than once).
Ans:
SELECT DISTINCT RegionID FROM STORES;
5.1.5 Display all the information for all stores whose ReigionID value is C
Ans:-
SELECT * FROM STORES WHERE RegionID = 'C';
5.1.8 Display the ProductID, ProductName, ProductPrice, and VendorName for all products. Sort the results by ProductID.
Ans:
SELECT ProductID,ProductName,ProductPrice,VendorName FROM products ORDER BY ProductID ASC;
5.1.10 Display the ProductID, ProductName, and ProductPrice for products in the category whose CategoryName value is Camping. Sort the results by ProductID.
Ans:
SELECT ProductID, ProductName,ProductPrice FROM products WHERE CategoryName="Camping" ORDER BY ProductID ASC;
5.1.11 Display the ProductID, ProductName, and ProductPrice for products that were sold in the zip code 60600. Sort the results by ProductID
Ans:
SELECT ProductID,ProductName,ProductPrice FROM products WHERE ZipCode=60600 ORDER BY PoductID ASC;