Question
Please copy SQL from Access and paste the queries into a TXT document.
Please use my initials (BTL) as an Alias in each query.
1. What items made by Mary Josephson were purchased?
2. What is the sum of all purchases made by Elizabeth Stanley (customerID = 1)
3. What is the average cost of all Earrings?
4. What items were purchased on 5/16/2012 and by which customer?
5. What is the highest purchase made by a single customer?
6. What is the most expensive item sold in the jewelry shop?
BONUS:
In a single SQL query answer the following question:
• How many items are cost more than the average item price?
• Due to a new tax, you must pay 5% of each invoice as a tax. What is the amount of money that you must give away?
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
/* Answer 1 */SELECT distinct ITEM.Description as BTL
FROM ITEM INNER JOIN ((CUSTOMER INNER JOIN PURCHASE ON CUSTOMER.CustomerID = PURCHASE.CustomerID) INNER JOIN PURCHASE_ITEM ON PURCHASE.InvoiceNumber = PURCHASE_ITEM.InvoiceNumber) ON ITEM.ItemNumber = PURCHASE_ITEM.ItemNumber
WHERE (((CUSTOMER.[lastname])="Josephson") AND ((CUSTOMER.FirstName)="Mary"));
/* Answer 2 */
SELECT Sum(PURCHASE.PreTaxAmount) AS BTL
FROM CUSTOMER INNER JOIN PURCHASE ON CUSTOMER.CustomerID = PURCHASE.CustomerID
HAVING (((CUSTOMER.CustomerID)=1));...