The problems for this chapter use a database for a simple department store that sells items to…

The problems for this chapter use a database for a simple department store that sells items to customers and wants to keep track of the invoices, the selling price (if an item is on sale), and the sales tax (7%) to be collected on some items. Every customer and invoice are assigned unique numbers. All items have a Universal Product Code (UPC) number and bar-code assigned to each unique item. Food and non-carbonated beverages are not taxed, but clothing, home goods, and most other items are.

The structure of the tables are described in the following crows foot ERD:
CH08_Invoice.png

Sample Data for the tables follow:

Customer

Customer_Id Customer_
FirstName
Customer_
LastName
Customer_
Address
Customer_
City
Customer_
State
Customer_
ZipCode
Customer_
Phone
Customer_Email
342 Linda Spangler 2323 Roanoke Pk Floyd VA 24987 555-555-5646 linda5646@nowhere.com
505 Rodney Ray 12399 27th Ave New York NY 10097 555-555-0909 rayray7@somewhere.com
776 Nancy Reno P.O.Box 98 Carter City KY 41155 555-555-2342 puppylove8@elsewhere.com
987 Gustov Jones 333 East Main St Jamestown VA 23099 555-555-9876 gustov99@somewhere.com

ItemType

ItemType_Id ItemType_Description
W Woman’s Clothing
M Men’s Clothing
WA Woman’s Accessories
MA Men’s Accessories
A General Accessories
O Other

ItemSize

ItemSize_Id ItemSize_Description
XS Extra Small
S Small
M Medium
L Large
XL Extra Large

Item

UPC Item_Description ItemType_Id ItemSize_Id Item_Price Item_Taxable
012345234569 Cream Blouse W S 29.95 1
012345234576 Cream Blouse W M 29.95 1
012345234588 Cream Blouse W L 29.95 1
012345234590 Cream Blouse W XL 29.95 1
012345234468 Blue Blouse W S 29.95 1
012345234475 Blue Blouse W M 29.95 1
012345234491 Blue Blouse W XL 29.95 1
012345224889 12 Inch Pearl Necklace WA 345.95 1
012345224126 10 Inch Pearl Necklace WA 298.95 1
012345334678 Explorer Cargo Shorts M S 33.45 1
012345334734 Explorer Cargo Shorts M M 33.45 1
012345334795 Explorer Cargo Shorts M L 33.45 1
012345334889 Explorer Cargo Shorts M XL 33.45 1
012345335101 Pink Silk Tie MA 67.55 1
012345335303 Pink and Green Silk Tie MA 67.55 1
012345999001 Yummy Bottled Water O 1.29 0

Invoice

Invoice_Number Customer_Id Invoice_Date Invoice_Taxable Invoice_NonTaxable Invoice_SalesTax Invoice_Total
10101 987 2015-07-27 29.95 2.58 2.1 34.63
10102 505 2015-07-27 33.45 0 2.34 35.79
10107 505 2015-07-28 59.99 1.29 4.2 65.48
10111 342 2015-07-28 262.89 0 18.4 281.29

InvoiceDetail

Invoice_Number UPC Detail_Quantity Detail_RegularPrice Detail_SellingPrice
10101 012345334795 1 33.45 29.95
10101 012345999001 2 1.29 1.29
10102 012345334889 1 33.45 33.45
10107 012345335303 1 67.55 59.99
10107 012345999001 1 1.29 1.29
10111 012345234576 1 29.95 29.95
10111 012345234475 1 29.95 29.95
10111 012345224126 1 298.95 202.99

You have been tasked to generate a report from the database using a single SQL statement to do the following:

List all items with the number of invoices that the items have been on and the total of the sales of that item. Display in order by type, description, and size.

Your generated output should look like:

UPC Item_Description ItemType_Id ItemSize_Id Invoice_Count Total_Sales
012345334795 Explorer Cargo Shorts M L 1 1
012345334734 Explorer Cargo Shorts M M 0
012345334678 Explorer Cargo Shorts M S 0
012345334889 Explorer Cargo Shorts M XL 1 1
012345335101 Pink Silk Tie MA 0
012345335303 Pink and Green Silk Tie MA 1 1
012345999001 Yummy Bottled Water O 2 3
012345234475 Blue Blouse W M 1 1
012345234468 Blue Blouse W S 0
012345234491 Blue Blouse W XL 0
012345234588 Cream Blouse W L 0
012345234576 Cream Blouse W M 1 1
012345234569 Cream Blouse W S 0
012345234590 Cream Blouse W XL 0
012345224126 10 Inch Pearl Necklace WA 1 1
012345224889 12 Inch Pearl Necklace WA 0

Fill in the blanks (remember a blank, drop “blank” as answer)

SELECT Item.UPC, Item.Item_Description, Item.ItemType_Id,
Item.ItemSize_Id, COUNT(Invoice.Invoice_Number) AS Invoice_Count,
SUM(InvoiceDetail.Detail_Quantity) AS Total_Sales
FROM item
InvoiceDetail ON item. = .UPC
Invoice ON .Invoice_Number = InvoiceDetail.
GROUP BY Item.UPC
ORDER BY Item.ItemType_id, Item.Item_Description, Item.ItemSize_Id;

Fill in the blanks with words that would best complete the passage.

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!