Given the structure and contents of the SaleCo database shown in Figure below, use SQL commands to answer problems: SaleCo Database A) Write the SQL code that will create the table structure for table: INVOICE. Note:  INV_NUMBER is the Primary Key CUS_CODE is the Foreign Key that references the CUSTOMER table B) Write the SQL code to enter two rows in the table CUSTOMER table. C) Write a SQL to compute and display for each Customer the Total Purchases, Number of Purchases and Average Purchases when the Total Purchases are more than 5000 dollars. D) Write a SQL to compute and display for each Product the Total Orders by Value, Number of Orders and Average Orders by Value, in descending order of Average Orders and the Product’s vendor (V_Name) is ‘Dell’. E) Write SQL code to list all vendors and the number of products they supply.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Given the structure and contents of the SaleCo database shown in Figure below, use SQL commands to answer problems:

SaleCo Database

A) Write the SQL code that will create the table structure for table: INVOICE.

Note:

  •  INV_NUMBER is the Primary Key

CUS_CODE is the Foreign Key that references the CUSTOMER table

B) Write the SQL code to enter two rows in the table CUSTOMER table.

C) Write a SQL to compute and display for each Customer the Total Purchases, Number of Purchases and Average Purchases when the Total Purchases are more than 5000 dollars.

D) Write a SQL to compute and display for each Product the Total Orders by Value, Number of Orders and Average Orders by Value, in descending order of Average Orders and the Product’s vendor (V_Name) is ‘Dell’.

E) Write SQL code to list all vendors and the number of products they supply.

CUSTOMER
INVOICE
PK CUs CODE
CUS LNAME
CUS FNAME
Cus INITIAL
CUS AREACODE
CUS PHONE
CUS BALANCE
INT(5)
PK INV_NUMBER INT(5)
FK CUS CODE
INV DATE
VARCHAR(50)
INT(5)
VARCHAR(50)
DATETIME
CHAR(1)
CHAR(3)
LINE
PK.
INV NUMBER
FK
CHAR(8)
INT(5)
DECIMAL(13,2)
PK LINE NUMBER INT(2)
FK PCODE
INT(5)
LINE _UNITS
LINE_PRICE
INT(4)
VENDOR
PRODUCT
DECIMAL(13,2)
PK V CODE
INT(5)
PK P_CODE
INT(5)
V_NAME
V_CONTACT
V_AREACODE
V_PHONE
V_STATE
v ORDER
VARCHAR(50)
VARCHAR(50)
VARCHAR(50)
P_DESCRIPT VARCHAR(50)
P_INDATE
DATETIME
P_QOH
INT(4)
VARCHAR(50)
P_MIN
INT(4)
VARCHAR(50)
P_PRICE
DECIMAL(13,2)
VARCHAR(50)
P DISCOUNT DECIMAL(13,2)
FK V_CODE
INT(5)
Transcribed Image Text:CUSTOMER INVOICE PK CUs CODE CUS LNAME CUS FNAME Cus INITIAL CUS AREACODE CUS PHONE CUS BALANCE INT(5) PK INV_NUMBER INT(5) FK CUS CODE INV DATE VARCHAR(50) INT(5) VARCHAR(50) DATETIME CHAR(1) CHAR(3) LINE PK. INV NUMBER FK CHAR(8) INT(5) DECIMAL(13,2) PK LINE NUMBER INT(2) FK PCODE INT(5) LINE _UNITS LINE_PRICE INT(4) VENDOR PRODUCT DECIMAL(13,2) PK V CODE INT(5) PK P_CODE INT(5) V_NAME V_CONTACT V_AREACODE V_PHONE V_STATE v ORDER VARCHAR(50) VARCHAR(50) VARCHAR(50) P_DESCRIPT VARCHAR(50) P_INDATE DATETIME P_QOH INT(4) VARCHAR(50) P_MIN INT(4) VARCHAR(50) P_PRICE DECIMAL(13,2) VARCHAR(50) P DISCOUNT DECIMAL(13,2) FK V_CODE INT(5)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY