Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this week's POTW, you will be working with the salesDB database and you will use the following SQL features to write queries. Aggregate functions
In this week's POTW, you will be working with the salesDB database and you will use the following SQL features to write queries.
- Aggregate functions
- Wildcards
- Group by and having clauses
The salesDB database contains 5 tables, and you can find the database diagram below.
List the last name of a customer, along with the total number of unique products they have ever purchased. (Hint: Quantity of a product is not required, just the total count of unique products)
vendor V_CODE INT(11) V_NAME VARCHAR(35) V_CONTACT VARCHAR(15) V_AREACODE CHAR(3) V_PHONE CHAR(8) V_STATE CHAR(2) V_ORDER CHAR(1) Indexes customer CUS_CODE INT(11) CUS_LNAME VARCHAR(15) CUS_FNAME VARCHAR(15) CUS_INITIAL CHAR(1) CUS_AREACODE CHAR(3) CUS_PHONE CHAR(8) CUS_BALANCE DECIMAL(9,2) CUS_PPBAL DECIMAL(9,2) Indexes product P_CODE VARCHAR(10) P_DESCRIPT VARCHAR(35) P_INDATE DATETIME P_QOH INT(11) P_MIN INT(11) P_PRICE DECIMAL(8,2) P_DISCOUNT DECIMAL(4,2) V_CODE INT(11) P_REORDER INT(11) Indexes +- line INV_NUMBER INT(11) LINE_NUMBER DECIMAL(2,0) P_CODE VARCHAR(10) LINE_UNITS DECIMAL(9,2) LINE_PRICE DECIMAL(9,2) Indexes Triggers invoice INV_NUMBER INT(11) CUS_CODE INT(11) INV_DATE DATETIME Indexes
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started