Question

customer ssn VARCHAR(9) firstname VARCHAR(45) lastname VARCHAR(45) phone VARCHAR(45) vendor ? vid INT vendorname VARCHAR(45)

Write a SQL query that shows the price of each order made by customers whose last name starts with the letter M. Display the order number, the last name on the order, and the price of the order (Order Price). Show the results with the highest order price first.

Write a SQL query that determines the most expensive item purchased in each order (Item Price). Display the order number, the date of the order, the last name of the customer that placed the order, and the price of the most expensive item on that order. Display in alphabetical order by last name.

Write a SQL query that determines and displays the total price of items sold (Total Price) before 2015 and after and including the year 2018.

Write a SQL query that determines the number of items purchased by each customer in the year 2013. Display the last name of each customer and the number of items purchased by each customer in that year in alphabetical order by last name.

AS ALWAYS, YOUR GENIUS ASSISTANCE IS MORE THAN GREATLY APPRECIATED!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) select i.itemname ,i.itemprice ,oi.oid ,c.lastname ,
from item i,order_item oi, order o,customer c
where i.sku=oi.sku
and oi.oid=o.ordemo
and o.ssn=c.ssn
and c.lastname like 'M%'
order by i.itemprice desc

2) select c.lastname,o.date,itmprice,orderid from(select max(i.itemprice) itmprice ,oi.oid orderid
from item i,order_item oi, order o
where i.sku=oi.sku
and oi.oid=o.ordemo
group by oi.oid),order o,customer c
where o.ordemo=oid
order by c.lastname

3)(select sum(item.itemprice) as totalprice
from item,order_item oi, order o
where item.sku=oi.sku
and oi.oid=o.ordemo
and year(o.date)<'2015')
union(select sum(item.itemprice)
from item,order_item oi, order o
where item.sku=oi.sku
and oi.oid=o.ordemo
and year(o.date)>='2018')

4)select c.lastname,o.ssn,a.noofitems,a.orderid from(select oid orderid,count(itemname) noofitems
from item,order_item
where item.sku=order_item.sku
group by oid) a,order o,customer c
where a.orderid=o.ordemo
o.ssn=c.ssn
and year(date)='2013'

Add a comment
Know the answer?
Add Answer to:
Write a SQL query that shows the price of each order made by customers whose last name starts wit...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (TCO 7) Write a query to display the orderid, order date, customer last name and firstname...

    (TCO 7) Write a query to display the orderid, order date, customer last name and firstname for all orders that have shipped. SalesRep Customer ReplD int PK CustomerID int LastName FirstName Commission Rate varchar(20) varchar(20) decimal(10,2) LastName FirstName Street City State Zipcode Balance ReplD varchar(20) varchar(20) varchar(20) varchar(20) char(2) char(5) HO----O decimal(10,2) Order OrderID PK int FK1 int FK1 CustomerID OrderDate ShipDate date date Part PK PartID int Orderline varchar(20) int Description UnitsOnHand Item Class Retail Cost PK,FK1 OrderID PartID...

  • (TCO 6) Write a query to list the customer first name, last name as a single...

    (TCO 6) Write a query to list the customer first name, last name as a single field with a heading of Customer along with the balance sorted by balance from lowest to highest. SalesRep Customer PK ReplD PK varchar(20) varchar(20) decimal(10,2) CustomerID int -OH Last Name FirstName Last Name varchar(20) Commission Rate FirstName varchar(20) Street varchar(20) City varchar(20) Order State char(2) Zipcode char(5) HO. ---OPK OrderID Balance decimal(10,2) ReplD int FK1 CustomeriD OrderDate ShipDate Part int int date date PK...

  • Write SQL query for the user follower and following count, select user's id, first name, last...

    Write SQL query for the user follower and following count, select user's id, first name, last name and age We were unable to transcribe this imageuser_ follow id INT following_user id INT followed user id INT step-taken id INT user user_id INT step id INT theme id INT name VARCHAR (100) weight INT first name VARCHAR(128) last_name VARCHAR (128) DOB DATE when started TIMESTAMP 卄 when finished TIMESTAMP rating TINYINT user interest ▼ user_id INT interest id INT step-theme ▼...

  • Write an sql query to list the customers last name, seating cost, seating tip and service...

    Write an sql query to list the customers last name, seating cost, seating tip and service date for all customers with last name Smith or jones or brown. SAMPLE DATA BASE (Key fields are underlined.) Employee EMP_ID EMP_FNAME EMP_LNAME EMP_STREET EMP_CITY EMP_STATE EMP_ZIP EMP_START_DATE Table TABLE D AREA ID TABLE SEATS Area AREA_ID AREA NAME AREA SUPERVISOR EMPLOYEE_ID Customer CUST ID CUST_LAST_NAME CUST_NUMBER_OF_GUESTS Assignment EMP ID TABLE ID Seating CUST_ID TABLE_ID SEATING COST SEATING DATE SEATING TIP

  • SQL query: Write an SQL query that will output the last name, employee id, hire date and department from the employee table. Pick only those employees whose department ID is specified in the employee...

    SQL query: Write an SQL query that will output the last name, employee id, hire date and department from the employee table. Pick only those employees whose department ID is specified in the employee table. If the employee id is 777, name is ABC and hire date is 01-JAN-2016, the output should look as follows - 'Stephen (Employee ID - 777) was hired on the 1st of January, 2016 – Department: 90'. Note - The date should not have preceding...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

  • Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins...

    Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins use from clause) Need to Create a Query to display products purchased by customers in Germany that were not purchased by customers in the US. Customers PK Customer D CompanyName Contact Name Contact Title Address City State OrRegion PostalCode Country Phone char(5) varchar(40) varchar(30) varchar(30) varchar(60) varchar(15) varchar(15) varchar(10) varchar(15) varchar(24) varchar(24) Order Details Orders PK OrderID int FK CustomerlD char(5) FK Employeeld int...

  • Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins...

    Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins use from clause) Need to Create a Query because Northwind Traders wants to make sure that all orders are shipped within 10 days. Display any orders that were not shipped within 10 days. Include the OrderID, the OrderDate, and the number of days it took before the order was shipped. Customers PK Customer D CompanyName Contact Name Contact Title Address City State OrRegion PostalCode...

  • SQL MS Acess 1. Display cid, clast, and cfirst for customers whose (last name starts with...

    SQL MS Acess 1. Display cid, clast, and cfirst for customers whose (last name starts with a “D” and has a “v” in the third position) or (first name ends with an “a”). 2. Display all the columns in Invoice for those invoices that have less than the average iprice. 3. Display all the columns in Customer for those customers who purchased a vehicle that has the same date value in icontract and isold. In other words, customers who signed...

  • Write just one SQL statement per question 1. Display Publisher ID, Publisher Name and Total Number...

    Write just one SQL statement per question 1. Display Publisher ID, Publisher Name and Total Number of Books published by each publisher. 2. List Publisher ID, Publisher Name, Title and price of the highest priced book. 3. List Order ID, Customer ID, Order Date, and Number of Items in each order. Order the data by Customer ID in ascending (A – Z) order. 4. Display Title, Category and Profit for each book in the children and computer category. 5. Display...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT