Answered step by step
Verified Expert Solution
Link Copied!

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 (5) exercises for each chapter from Week 2's readings. All of these exercises use the my_guitar_shop database Download my_guitar_shop database.
Your first task is to create this my_guitar_shop in MySQL using the techniques learned in Week 1's readings. The Create db script is on the eLumin Windows desktop in the class files folder.
Chapter 3: 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: product_code, product_name, list_price, and discount_percent. 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 full_name that joins the last_name and first_name 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 last_name 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:
product_name The product_name column
list_price The list_price column
date_added The date_added column
Return only the rows with a list price thats greater than 500 and less than 2000.
Sort the result set by the date_added column in descending sequence.
Write a SELECT statement that returns these column names and data from the Products table:
product_name The product_name column
list_price The list_price column
discount_percent The discount_percent column
discount_amount A column thats calculated from the previous two columns
discount_price A column thats calculated from the previous three columns
Round the discount_amount and discount_price columns to 2 decimal places.
Sort the result set by the discount_price column in descending sequence.
Use the LIMIT clause so the result set contains only the first 5 rows.
Write a SELECT statement that returns these column names and data from the Order_Items table:
item_id The item_id column
item_price The item_price column
discount_amount The discount_amount column
quantity The quantity column
price_total A column thats calculated by multiplying the item price by the quantity
discount_total A column thats calculated by multiplying the discount amount by the quantity
item_total A column thats calculated by subtracting the discount amount from the item price and then multiplying by the quantity
Only return rows where the item_total is greater than 500.
Sort the result set by the item_total column in descending sequence.
Chapter 4: 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: category_name, product_name, list_price.
Sort the result set by the category_name column and then by the product_name column in ascending sequence.
Write a SELECT statement that joins the Customers table to the Addresses table and returns these columns: first_name, last_name, line1, city, state, zip_code.
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: first_name, last_name, line1, city, state, zip_code.
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, Order_Items, and Products tables. This statement should return these columns: last_name, first_name, order_date, product_name, item_price, discount_amount, and quantity.
Use aliases for the tables.
Sort the final result set by the last_name, order_date, and product_name columns.
Use the UNION operator to generate a result set consisting of three columns from the Orders table:
ship_status A calculated column that contains a value of SHIPPED or NOT SHIPPED
order_id The order_id column
order_date The order_date column
If the order has a value in the ship_date column, the ship_status column should

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

1. How would you describe The Lakes Distillery brand positioning?

Answered: 1 week ago

Question

jackson 3.1

Answered: 1 week ago

Question

4. How has e-commerce affected business-to-business transactions?

Answered: 1 week ago