Question: Using the My Guitar Shop database you installed in Module 1 , develop the following queries. SUBMIT A SCREENSHOT OF EACH STEP. 1 . Write
Using the My Guitar Shop database you installed in Module develop the following queries. SUBMIT A SCREENSHOT OF EACH STEP.
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 two 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 five rows. Submit a screenshot.
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. Submit a screenshot.
Write a SELECT statement that returns the productname and listprice columns from the Products table.
Return one row for each product that has the same list price as another product.
Hint: Use a selfjoin to check that the productid columns arent equal but the listprice columns are equal.
Sort the result set by the productname column. Submit a screenshot.
Write a SELECT statement that returns these two columns:
categoryname The categoryname column from the Categories table
productid The productid column from the Products table
Return one row for each category that has never been used. Hint: Use an outer join and only return rows where the productid column contains a null value. Submit a screenshot.
Write an INSERT statement that adds this row to the Customers table:
emailaddress: rick@raven.com
password: empty string
firstname: Rick
lastname: Raven
Use a column list for this statement. Submit a screenshot.
Write a SELECT statement that answers this question: Which customers have ordered more than one product? Return these columns:
The emailaddress column from the Customers table
The count of distinct products from the customers orders
Sort the result set in ascending sequence by the emailaddress column. Submit a screenshot.
Write a SELECT statement that answers this question: What is the total quantity purchased for each product within each category? Return these columns
The categoryname column from the category table
The productname column from the products table
The total quantity purchased for each product with orders in the OrderItems table
Use the WITH ROLLUP operator to include rows that give a summary for each category name as well as a row that gives the grand total.
Use the IF and GROUPING functions to replace null values in the categoryname and productname columns with literal values if theyre for summary rows. Submit a screenshot.
Write and execute a script that creates a user with a username using your firstname initial and lastname and password of your choosing. This user should be able to connect to MySQL from any computer.
This user should have SELECT, INSERT, UPDATE, and DELETE privileges for the Customers, Addresses, Orders, and OrderItems tables of the My Guitar Shop database.
However, this user should only have SELECT privileges for the Products and Categories tables. Also, this user should not have the right to grant privileges to other users.
Check the privileges for the user by using the SHOW GRANTS statement. Submit a screenshot.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
