Question

ResuitsMessages cname city cid 2 Basics Dallas c002 12 3 Allied las c003 8 ACME Duluth c004 8 5 ACME Kyoto c006 0 aid aname city 1a01Smith New York 6 2 a02 Jones Newark 3 a03 Brown Tokyo 7 4a04 Gray New York6 5 a05 Otasi Duluth 5 6 a06 Smith Dallas 5

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Table names are not memtioned i am considering it as follows:

1. customertbl:

2. agenttbl:

ResuitsMessages cname city cid 2 Basics Dallas c002 12 3 Allied las c003 8 ACME Duluth c004 8 5 ACME Kyoto c006 0 aid aname c

producttbl:

pid pname city quantity price 1 p01comb Dallas 111400 0.5 2 p02 brush Newark 203000 0.5 3 p03 razor Duluth 150600 1 p04 pen D

ordertbl:

ordno month cid aid pid ty dollars 1 1011 an c001 a01 p 1000 450 2 1012 an c00 a0 p1 1000 450 3 1019 feb c001 a02 p02 400 180

ordno month cid aid pid ty dollars 91013 jac002 a03 p3 1000 880 0 1026 mayc002 a05 p03 800 704 1015 jac003 a03 p05 1200 1104

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:

aid a03 a01 a03 a06 aname city BrownTokyo Smith New York BrownTokyo Smith Dallas cid 7 c003 6 C006 7 c006 5 c006 prcnt

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:

pid pname cid p05 po5 peni c003 p01comb C006 P07 case pencil c003 C006 p01comb C006

Question 5:

Answer:

SELECT sum(dollars)
FROM ordertbl o;

Output:

9802

Add a comment
Know the answer?
Add Answer to:
SQL 3) List aid of Agents that placed an order for customer c003 or customer c006....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using the CAP database handout. Write the relational algebra statement to answer the following question. Then...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT