
<p>▶ANSWERS TO FIREDUP PROJECT QUESTIONS</p><p>Assume that FiredUp has created a database with the following tables:</p><p>CUSTOMER (CustomerSK, Name, Phone, EmailAddress)</p><p>STOVE (SerialNumber, Type, Version, DateOfManufacture)</p><p>REGISTRATION ( CustomerS K, SerialNumbe r, Date)</p><p>STOVE_REPAIR (RepairInvoiceNumber, SerialNumber, Date, Description, Cost, CustomerSK)</p><p>Code SQL for the following. Assume that all dates are in the format mmddyyyy.</p><p>A. Show all of the data in each of the four FiredUp tables.</p><p>SELECT * FROM CUSTOMER;</p><p>SELECT * FROM STOVE;</p><p>SELECT * FROM REGISTRATION;</p><p>SELECT * FROM STOVE_REPAIR;</p><p>B. List the Versions of all stoves.</p><p>SELECT Version FROM STOVE;</p><p>To list each very only once use:</p><p>SELECT DISTINCT Version FROM STOVE; C. List the Versions of all stoves of the type ‘Fired Now’.</p><p>SELECT Version FROM STOVE WHERE Type = ‘Fired Now’;</p><p>D. List the SerialNumber and Date of all registrations in the year 2002.</p><p>SELECT SerialNumber, Date FROM REGISTRATION WHERE Date Like ‘%2002’;</p><p>E. List the SerialNumber and Date of all registrations in February. Use the underscore (_) wildcard.</p><p>SELECT SerialNumber, Date FROM REGISTRATION WHERE Date Like ‘02______;</p><p>F. List the SerialNumber and Date of all registrations in February. Use the percent (%) wildcard.</p><p>SELECT SerialNumber, Date FROM REGISTRATION WHERE Date Like ‘02%’;</p><p>G. List the names and email addresses of all customers who have an email address.</p><p>SELECT Name, EmailAddress FROM CUSTOMER WHERE EmailAddress IS NOT NULL;</p><p>H. List the names of all customers who do not have an EmailAddress; present the results in descending sorted order of Name.</p><p>SELECT Name, EmailAddress FROM CUSTOMER WHERE EmailAddress IS NULL ORDER BY Name;</p><p>I. Determine the maximum cost of a stove repair.</p><p>SELECT MAX (Cost) FROM STOVE_REPAIR;</p><p>J. Determine the average cost of a stove repair.</p><p>SELECT AVG (Cost) FROM STOVE_REPAIR;</p><p>K. Count all stoves.</p><p>SELECT COUNT (*) FROM STOVE;</p><p>L. Count all stoves of each type and display the Type and count.</p><p>SELECT Type, COUNT (*) FROM STOVE GROUP BY Type;</p><p>M. List the name and email addresses of all customers who have had a stove repair that cost more than $50. Use a subquery.</p><p>SELECT Name, EmailAddress FROM CUSTOMER WHERE CustomerSK IN (SELECT CustomerSK FROM STOVE_REPAIR WHERE Cost > 50.00);</p><p>N. List the names and email addresses of all customers who have registered a stove of the type ‘FiredNow’. Use a subquery.</p><p>SELECT Name, EmailAddress FROM CUSTOMER WHERE CustomerSK IN (SELECT CustomerSK FROM REGISTRATION WHERE SerialNumber IN (SELECT SerialNumber FROM STOVE WHERE Type = ‘FiredNow’);</p><p>O. List the names and email addresses of all customers who have had a stove repair that cost more than $50. Use join with the JOIN ON syntax. SELECT Name, EmailAddress FROM CUSTOMER JOIN (REGISTRATION JOIN STOVE_REPAIR ON REGISTRATION.SerialNumber = STOVE_REPAIR.Serial_Number) ON CUSTOMER.CustomerSK = REGISTRATION.CustomerSK WHERE STOVE_REPAIR.Cost > 50.00;</p><p>P. List the names and email addresses of all customers who have registered a stove of type ‘FiredNow’. Use join with the JOIN ON syntax.</p><p>SELECT Name, EmailAddress FROM CUSTOMER JOIN REGISTRATION ON CUSTOMER.CustomerSK = REGISTRATION.CustomerSK WHERE STOVE_REPAIR.Type = ‘FiredNow’;</p><p>Q. List the names, email addresses, and registration date of all customer registrations.</p><p>SELECT Name, EmailAddress, Date FROM CUSTOMER, REGISTRATION WHERE CUSTOMER.CustomerSK = REGISTRATION.CustomerSK; R. Show the names and email addresses of all customers who have registered a stove, and have had any stove repaired.</p><p>SELECT Name, EmailAddress FROM CUSTOMER WHERE CustomerSK IN (SELECT CustomerSK FROM REGISTRATION) AND CustomerSK IN (SELECT CustomerSK FROM STOVE_REPAIR);</p><p>S. Show the names and email addresses of all customers who have registered a stove, but who have not had any stove repaired.</p><p>SELECT Name, EmailAddress FROM CUSTOMER WHERE CustomerSK IN (SELECT CustomerSK FROM REGISTRATION) AND CustomerSK NOT IN (SELECT CustomerSK FROM STOVE_REPAIR);</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-