Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help writing a query

Status
Not open for further replies.

NewBe2

Programmer
Jun 9, 2001
4
ZA
I have two tables (again) - CUSTOMER and SLSREP
The fields are:
CUSTOMER (Cus_Name, Slsr_Number, Curr_Balance ...)
SLSREP (Slsr_Number, Slsr_Name ...)
The question is:
Find the total of the current balances for sales representatives with at least three customers - the sales representative's name and number must also be in the result.

Thanx in advance.
 
Dear NewBe2:

I tried this and it seems to work. I named the tables test-slsrep and test-customer so I don't forget to delete them. ( Also misspelled slsr_number as slsr_numer).

Let me know if there is a problem with it.

SELECT [test-slsrep].slsr_numer, [test-slsrep].slsr_name, Count([test-customer].cus_name) AS CountOfcus_name, Sum([test-customer].current_balance) AS SumOfcurrent_balance
FROM [test-customer] INNER JOIN [test-slsrep] ON [test-customer].slsr_number = [test-slsrep].slsr_numer
GROUP BY [test-slsrep].slsr_numer, [test-slsrep].slsr_name
HAVING (((Count([test-customer].cus_name))>2));
 
It works with no problem !!!
Thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top