Question

EXERCISE Provide working SQL DML statements for the following database schema and queries CUSTOMER (ID, Type, Firstname, Last
0 0
Add a comment Improve this question Transcribed image text
Answer #1

SQL Query 16 :

select Orders.ID,lastname,sum(Quantity*Price) TotalAmount
from orders,customer,Inventory
where
Orders.Customer_FK=Customer.ID and
Orders.Item_FK=Inventory.ID
group by Orders.ID,lastname
having TotalAmount>=70;

  • This SQL query joins three tables orders,customer,Inventory and will return the result

***********************************

SQL query 17 :

select Orders.ID,lastname,sum(Quantity*Price) TotalAmount,
count(distinct(Item_FK)) NumberOfDifferentItems
from orders,customer,Inventory
where
Orders.Customer_FK=Customer.ID and
Orders.Item_FK=Inventory.ID and customer.type like 'Restaurant Owner'
group by Orders.ID,lastname
having TotalAmount>=70 and NumberOfDifferentItems<3;

  • This SQL query joins three tables orders,customer,Inventory and will return the result
  • Note :Here customer type value is taken as Restaurant Owner
Add a comment
Know the answer?
Add Answer to:
EXERCISE Provide working SQL DML statements for the following database schema and queries CUSTOMER (ID, Type,...
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
  • Given the following relational schema, write queries in SQL to answer the English questions. There is...

    Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...

  • Sales Database: Customer(custId, lastName, firstName, address, phone, creditLimit) Order(orderNumber, date, total, custId) LineItem(orderNumber, itemNumber, qtyOrdered) Item(itemNumber,...

    Sales Database: Customer(custId, lastName, firstName, address, phone, creditLimit) Order(orderNumber, date, total, custId) LineItem(orderNumber, itemNumber, qtyOrdered) Item(itemNumber, itemName, price) Give the SQL required to create the LineItem table in the Sales Database with the required keys and appropriate data types for the attributes.

  • 2. SQL queries (40 points total, 5 points each query) Write SQL query statements to query...

    2. SQL queries (40 points total, 5 points each query) Write SQL query statements to query the following Hotel Room Booking Database Tables. "cid" is Customer ID. "rid" is Room ID. "bid" is Booking ID. "dob" means Date of Vwwww Birth; "beds" means the number of beds in the room which is normally 1 or 2 beds. "DueDate" and "DueAmount" are the payment due dates and due amounts of this booking. Customers fname name phone email cid dob zipcode Rooms...

  • 7. Using the provided schema of a Purchase Order Administration database, write the following queries in...

    7. Using the provided schema of a Purchase Order Administration database, write the following queries in SQL. (In the schema, bold attributes are primary keys and italicized attributes are foreign keys.) SUPPLIER (SUPNR, SUPNAME, SUPADDRESS, SUPCITY, SUPSTATUS) SUPPLIES (SUPNR, PRODNR, PURCHASE_PRICE, DELIV_PERIOD) PRODUCT (PRODNR, PRODNAME, PRODTYPE, AVAILABLE_QUANTITY) PO_LINE (PONR, PRODNR, QUANTITY) PURCHASE_ORDER (PONR, PODATE, SUPNR) 7d) Write a nested SQL query to retrieve the supplier number, supplier name, and supplier status of each supplier who has a higher supplier status...

  • Given the following relational schema, write queries in SQL to answer the English questions. There is...

    Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...

  • Using the database: Write SQL queries for each of the questions below. 1. Find the media...

    Using the database: Write SQL queries for each of the questions below. 1. Find the media type which has 100 or more tracks. Print the name of such media type. Number of rows returned in the result = 3 A) Find the playlists which have one or more tracks that have never been purchased in California (CA). Print the Id, and the name of such playlists. Number of rows returned in the result = 18 B) Find the customers who...

  • Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587...

    Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587 When all of your queries are complete, cut and paste the SQL Syntax into a word document. In order to see what the column names are, you need to click on the table and then Columns to see the field names. Make sure to include column headings that make sense in the queries (use the as “Field Name” after the field selected). Multi-table Queries...

  • Given the following relational schema, write queries in SQL to answer the English questions. The Access...

    Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...

  • NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR...

    NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR FOREIGN etc Customer [ CustID, LastName, FirstName, Address, City, State, Zip, Phone, Fax, Email] Product [ ProdID, Description, Color, Size, Pack] Sales [ TransID, CustID, ProdID, Price, Quantity, Amount] Write SQL statement to produce a list of unique products and their prices from the Sales table. Please ensure that the products do not repeat. Write an SQL statement to list ProdID and Description for...

  • Create the following SQL Server queries that access the Northwind database Same as problem 3 but,...

    Create the following SQL Server queries that access the Northwind database Same as problem 3 but, limit the list to all customers who placed 3 or more orders. The product id, product name, last date that the product was ordered for all items in the Grains/Cereals category. (Hint: Use MAX) The product ID, product name, and number of distinct customers who ordered that product in 1996 Thank you. Categories Customers Employees Order Details Orders Products Shippers 9 CategoryID CategoryName Description...

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