Question: Consider the Customers-Agents-Products (CAP) database with schema below. CUSTOMERS ( cid , cname, city, discnt) AGENTS ( aid , aname, city, percent) PRODUCTS ( pid
Consider the Customers-Agents-Products (CAP) database with schema below.
CUSTOMERS (cid, cname, city, discnt)
AGENTS (aid, aname, city, percent)
PRODUCTS (pid, pname, city, quantity, price)
ORDERS (ordno, month, year, cid, aid, pid, qty, dollars)
where bold in each relation form the primary key.
SQL Queries with aggregates:
1): Get the names of agents who have ordered at least three different products for the same customer.
2): List the names and ids of customers who, in 2020, placed purchase orders through at least 10 agents per month.
3): List the names and ids of customers who (a) have only ordered through agents in their own cities, and (b) placed the highest number of purchase orders.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
