Table : PURCHASE_ORDER ORDER_NO AMOUNT ORDER DATE CUSTOMER_ID SALESMAN ID DELIVERY_ DATE 1001 300 05-03-2017 2001 3001 05-05-2017 1002 200.20 10-07-2017 2002 3003 10-10-2017 1003 600 12-06-2017 2005 3002 12-08-2017 1004 400.25 10-05-2017 2003 3004 10-07-2017 1005 500.10 03-08-2017 2004 3005 03-05-2017 1006 400 10-07-2017 2005 3006 10-10-2017 Table: PURCHASE DETAILS ORDER_NO PRODUCT_NAME PRICE QUANTITY 1001 KEYBOARD 56 100 1002 MONITOR 36 200 1003 MOUSE 6 00 1004 HARD DISK 58 300 1005 RAM 25 500 1007 CABINET 100 a) Write a SQL query to display PRODUCT_NAME, ORDER_DATE and find number of years between the DELIVERY_DATE from the CURRENT DATE. [Hint: Use ON Clause). b) Write a SQL query to display matched records from PURCHASE_ORDER table and all records from PURCHASE_DETAILS. c) Write an SQL query to display ORDER NO, PRODUCT_NAME from table ORDER_DETAILS of products where the price is less than average price of products. (Hint: Use Subqueryl-

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Table : PURCHASE_ORDER
ORDER_NO AMOUNT ORDER DATE CUSTOMER_ID SALESMAN_ID DELIVERY DATE
1001
300
05-03-2017
2001
3001
05-05-2017
1002
200.20
10-07-2017
2002
3003
10-10-2017
1003
600
12-06-2017
2005
3002
12-08-2017
1004
400.25
10-05-2017
2003
3004
10-07-2017
1005
500.10
03-08-2017
2004
3005
03-05-2017
1006
400
10-07-2017
2005
3006
10-10-2017
Table: PURCHASE _DETAILS
ORDER_NO
PRODUCT_NAME
PRICE
QUANTITY
1001
KEYBOARD
56
100
1002
MONITOR
36
200
1003
MOUSE
100
1004
HARD_DISK
58
300
1005
RAM
25
500
1007
CABINET
100
a) Write a SQL query to display PRODUCT_NAME, ORDER DATE and find number of years between
the DELIVERY_ DATE from the CURRENT DATE
[Hint: Use ON Clause].
b) Write a SQL query to display matched records from PURCHASE_ORDER table and all records from
PURCHASE_DETAILS.
c) Write an SQL query to display ORDER_NO, PRODUCT_NAME from table ORDER_DETAILS of
products where the price is less than average price of products. [Hint: Use Subquery].
d) Write an SQL query to display ORDER_NO, PRODUCT_NAME and QUANTITY from
PURCHASE _DETAILS table where the quantity is greater than all values in quantity for products
Mouse and keybbard. [Hint: Use Subquery).
Transcribed Image Text:Table : PURCHASE_ORDER ORDER_NO AMOUNT ORDER DATE CUSTOMER_ID SALESMAN_ID DELIVERY DATE 1001 300 05-03-2017 2001 3001 05-05-2017 1002 200.20 10-07-2017 2002 3003 10-10-2017 1003 600 12-06-2017 2005 3002 12-08-2017 1004 400.25 10-05-2017 2003 3004 10-07-2017 1005 500.10 03-08-2017 2004 3005 03-05-2017 1006 400 10-07-2017 2005 3006 10-10-2017 Table: PURCHASE _DETAILS ORDER_NO PRODUCT_NAME PRICE QUANTITY 1001 KEYBOARD 56 100 1002 MONITOR 36 200 1003 MOUSE 100 1004 HARD_DISK 58 300 1005 RAM 25 500 1007 CABINET 100 a) Write a SQL query to display PRODUCT_NAME, ORDER DATE and find number of years between the DELIVERY_ DATE from the CURRENT DATE [Hint: Use ON Clause]. b) Write a SQL query to display matched records from PURCHASE_ORDER table and all records from PURCHASE_DETAILS. c) Write an SQL query to display ORDER_NO, PRODUCT_NAME from table ORDER_DETAILS of products where the price is less than average price of products. [Hint: Use Subquery]. d) Write an SQL query to display ORDER_NO, PRODUCT_NAME and QUANTITY from PURCHASE _DETAILS table where the quantity is greater than all values in quantity for products Mouse and keybbard. [Hint: Use Subquery).
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Single Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education