- #1
- 7,010
- 10,477
Hi all,
I am reviewing some material and I have been stuck on these (I am a slow starter, I guess)
1) I have the table Customer, which has an entry on sales reps for customers. I want to know which sales
rep handles the most customers. Here is what is given
Customer ( CustNum PK, CustName, RepNum,...)
Where RepNum is the sales rep that handles a given customer.
My attempt is : select repnum from customer, group by repnum having Count(RepNum) =
(select max(count(repnum)) from customer, group by repnum)
Does this work?
-------------------------------------------------------
2) I want to know which warehouse houses the most products (given by OnHand below), using the table part:
Part(PartNum, warehouse, OnHand ,... )
My attempt: select warehouse from part group by warehouse having sum(OnHand) = (select
max(sum(onHand)) from part, group by warehouse ).
Does that work?
Thanks. Sorry, My SQL is not running, so I cannot test the queries myself.
I am reviewing some material and I have been stuck on these (I am a slow starter, I guess)
1) I have the table Customer, which has an entry on sales reps for customers. I want to know which sales
rep handles the most customers. Here is what is given
Customer ( CustNum PK, CustName, RepNum,...)
Where RepNum is the sales rep that handles a given customer.
My attempt is : select repnum from customer, group by repnum having Count(RepNum) =
(select max(count(repnum)) from customer, group by repnum)
Does this work?
-------------------------------------------------------
2) I want to know which warehouse houses the most products (given by OnHand below), using the table part:
Part(PartNum, warehouse, OnHand ,... )
My attempt: select warehouse from part group by warehouse having sum(OnHand) = (select
max(sum(onHand)) from part, group by warehouse ).
Does that work?
Thanks. Sorry, My SQL is not running, so I cannot test the queries myself.