Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete all of the exercises below. There are five ( 5 ) exercises for each chapter from Week 2 ' s readings. All of these
Complete all of the exercises below. There are five exercises for each chapter from Week s readings. All of these exercises use the myguitarshop database Download myguitarshop database.
Your first task is to create this myguitarshop in MySQL using the techniques learned in Week s readings. The Create db script is on the eLumin Windows desktop in the class files folder.
Chapter : How to Retrieve Data from a Single Table
Enter and run your own SELECT statements submit all in Notepad saved in sql file format. Number each answer using commenting marks.
In these exercises, youll enter and run your own SELECT statements.
Write a SELECT statement that returns four columns from the Products table: productcode, productname, listprice, and discountpercent. Then, run this statement to make sure it works correctly.
Add an ORDER BY clause to this statement that sorts the result set by list price in descending sequence. Then, run this statement again to make sure it works correctly. This is a good way to build and test a statement, one clause at a time.
Write a SELECT statement that returns one column from the Customers table named fullname that joins the lastname and firstname columns.
Format this column with the last name, a comma, a space, and the first name like this:
Doe, John
Sort the result set by the lastname column in ascending sequence.
Return only the customers whose last name begins with letters from B to J
NOTE: When comparing strings of characters, B comes before any string of characters that begins with B For example, B comes before Book
Write a SELECT statement that returns these columns from the Products table:
productname The productname column
listprice The listprice column
dateadded The dateadded column
Return only the rows with a list price thats greater than and less than
Sort the result set by the dateadded column in descending sequence.
Write a SELECT statement that returns these column names and data from the Products table:
productname The productname column
listprice The listprice column
discountpercent The discountpercent column
discountamount A column thats calculated from the previous two columns
discountprice A column thats calculated from the previous three columns
Round the discountamount and discountprice columns to decimal places.
Sort the result set by the discountprice column in descending sequence.
Use the LIMIT clause so the result set contains only the first rows.
Write a SELECT statement that returns these column names and data from the OrderItems table:
itemid The itemid column
itemprice The itemprice column
discountamount The discountamount column
quantity The quantity column
pricetotal A column thats calculated by multiplying the item price by the quantity
discounttotal A column thats calculated by multiplying the discount amount by the quantity
itemtotal A column thats calculated by subtracting the discount amount from the item price and then multiplying by the quantity
Only return rows where the itemtotal is greater than
Sort the result set by the itemtotal column in descending sequence.
Chapter : How to Retrieve Data from Two or More Tables
Write a SELECT statement that joins the Categories table to the Products table and returns these columns: categoryname, productname, listprice.
Sort the result set by the categoryname column and then by the productname column in ascending sequence.
Write a SELECT statement that joins the Customers table to the Addresses table and returns these columns: firstname, lastname, line city, state, zipcode.
Return one row for each address for the customer with an email address of allan.sherwood@yahoo.com.
Write a SELECT statement that joins the Customers table to the Addresses table and returns these columns: firstname, lastname, line city, state, zipcode.
Return one row for each customer, but only return addresses that are the shipping address for a customer.
Write a SELECT statement that joins the Customers, Orders, OrderItems, and Products tables. This statement should return these columns: lastname, firstname, orderdate, productname, itemprice, discountamount, and quantity.
Use aliases for the tables.
Sort the final result set by the lastname, orderdate, and productname columns.
Use the UNION operator to generate a result set consisting of three columns from the Orders table:
shipstatus A calculated column that contains a value of SHIPPED or NOT SHIPPED
orderid The orderid column
orderdate The orderdate column
If the order has a value in the shipdate column, the shipstatus column should
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started