Purchase Solution

Guitar Database Query Assistance

Not what you're looking for?

Ask Custom Question

I am having trouble running several query's for a database I created in Microsoft SQL Management Studio. The data base code is attached.

1. Create a view named CustomerAddresses that shows the shipping and billing addresses for each customer in the MyGuitarShop database. This view should return these columns from the Customers table: CustomerID, EmailAddress, LastName and FirstName. This view should return these columns from the Addresses table: BillLine1, BillLine2, BillCity, BillState, BillZip, ShipLine1, ShipLine2, ShipCity, ShipState, and ShipZip.

2. Write a SELECT statement that returns these columns from the CustomerAddresses view that you created in exercise 1: CustomerID, LastName, FirstName, BillLine1.

3. Write an UPDATE statement that updates the CustomerAddresses view you created in exercise 1 so it sets the first line of the shipping address to "1990 Westwood Blvd." for the customer with an ID of 8.

4. Create a view named OrderItemProducts that returns columns from the Orders, OrderItems, and Products tables.
This view should return these columns from the Orders table: OrderID, OrderDate, TaxAmount, and ShipDate.
This view should return these columns from the OrderItems table: ItemPrice, DiscountAmount, FinalPrice (the discount amount subtracted from the item price), Quantity, and ItemTotal (the calculated total for the item).
This view should return the ProductName column from the Products table.

5. Create a view named ProductSummary that uses the view you created in exercise 4. This view should return some summary information about each product.
Each row should include these columns: ProductName, OrderCount (the number of times the product has been ordered), and OrderTotal (the total sales for the product).

6. Write a SELECT statement that uses the view that you created in exercise 5 to get total sales for the five best selling products.

Purchase this Solution

Solution Summary

This solution provides SQL Statements to create and select from multiple views for a retail guitar shop. The working SQL statements for the provided database includes updating data.

Solution Preview

Hello student,

Here are the queries

USE MyGuitarShop;
GO
/*1. Create a view named CustomerAddresses that shows the shipping and billing addresses for each customer in the MyGuitarShop database.
This view should return these columns from the Customers table: CustomerID, EmailAddress, LastName and FirstName.
This view should return these columns from the Addresses table: BillLine1, BillLine2, BillCity, BillState, BillZip, ShipLine1, ShipLine2, ShipCity, ShipState, and ShipZip.
*/

IF OBJECT_ID('CustomerAddresses') IS NOT NULL
DROP VIEW CustomerAddresses;
GO

CREATE VIEW CustomerAddresses
AS
SELECT
C.CustomerID,
C.EmailAddress,
C.LastName,
C.FirstName,
B.Line1 AS BillLine1,
B.Line2 AS BillLine2,
B.City AS BillCity,
B.State AS BillState,
B.ZipCode AS BillZip,
S.Line1 AS ShipLine1,
S.Line2 AS ShipLine2,
S.City AS ShipCity,
S.State AS ShipState,
S.ZipCode AS ShipZip
FROM Customers AS C
JOIN Addresses AS B
ON ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.