SQL
3) List aid of Agents that placed an order for customer c003 or customer c006.
4) List pid of Products that were Ordered for customer c003 or customer c006.
5) List the sum in dollars of all orders
Table names are not memtioned i am considering it as follows:
1. customertbl:
2. agenttbl:
producttbl:
ordertbl:
Question 3:
Answer:
SELECT a.*,o.cid
FROM ordertbl o
INNER JOIN agenttbl a
ON a.aid = o.aid
WHERE o.cid = 'c003' OR o.cid = 'c006';
Output:
Question 4:
Answer:
SELECT p.id,p.panme,o.cid
FROM ordertbl o
INNER JOIN producttbl p
ON p.pid = o.pid
WHERE o.cid = 'c003' OR o.cid = 'c006';
Output:
Question 5:
Answer:
SELECT sum(dollars)
FROM ordertbl o;
Output:
SQL 3) List aid of Agents that placed an order for customer c003 or customer c006....
Using the CAP database handout. Write the relational algebra
statement to answer the following question. Then write the SQL
statement to answer the same question.
Get aids of agents who place individual orders in dollar value
greater than $500 for customers living in Kyoto.
Chanter 2 The Relational Model O'Neil, P., & O'Neil, E (200). Database prineiples programming performance (2d ed.). San Franciscu: Morgan Kaufmann. PRODUCTS pd pname city p0 combl111400C.so p02brushNewark 2030000.S0 pzorDuluth 150600 1.00 CUSTOMERS Cname city discat...