Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL & Subquery Problem

Author  Topic 

Avishant
Starting Member

1 Post

Posted - 2011-03-14 : 19:31:35


CUSTOMER (CustomerID, LastName, FirstName, Phone, Email)
PURCHASE (InvoiceNumber, Date, PreTaxAmount, CustomerID)
PURCHASE_ITEM (InvoiceNumber, ItemNumber, RetailPrice)
ITEM (ItemNumber, Description, Cost, ArtistName)
where
CustomerID in PURCHASE must exist in CustomerID in CUSTOMER
InvoiceNumber in PURCHASE_ITEM must exist in InvoiceNumber in PURCHASE
ItemNumber in PURCHASE_ITEM must exist in ItemNumber in ITEM.
Q1: Write CREATE TABLE statements for each of these tables. Include any foreign key
constraints appropriate for each of these tables. Make your own assumptions regarding
cascading updates and deletions and justify those assumptions.

Q2: Write a SQL statement to list the LastName and FirstName of customers who have
made at least one purchase with PreTaxAmount greater than $200. Use a subquery.
Q3: Write a SQL statement to list the LastName and FirstName of customers who have
purchased an item that was created by an artist with a name that begins with the letter J.
Use a subquery.
Q4: Write a SQL statement to show the sum of PreTaxAmount for each ArtistName but
exclude any items that were part of purchases with a PreTaxAmount less than $25.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-14 : 19:53:09
Avishant,
You won't find many people here who will do your homework, but if you give it your best shot first, you'll find many people who will help you.

Jim


Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -