A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

trouble with query



 
 
Thread Tools Display Modes
  #1  
Old May 25th, 2004, 03:24 AM
Gary B
external usenet poster
 
Posts: n/a
Default trouble with query

MASTER
Table: CHARGES
Fields: ChargesKey, ChargesDate

DETAIL
Table: SERVICES
Fields: ServicesKey, ServicesDate, SalesRep

I need to return the Count of CHARGES(ChargesKey) for each SalesRep

Thank you.


  #2  
Old May 25th, 2004, 04:32 AM
Graham R Seach
external usenet poster
 
Posts: n/a
Default trouble with query

Gary,

Untested - but this should do it:

SELECT Count(CHARGES.*) As CountOfCharges,
SERVICES.SalesRep
FROM CHARGES
INNER JOIN SERVICES
ON SERVICES.ServicesKey = CHARGES.ChargesKey
GROUP BY SERVICES.SalesRep

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"Gary B" wrote in message
...
MASTER
Table: CHARGES
Fields: ChargesKey, ChargesDate

DETAIL
Table: SERVICES
Fields: ServicesKey, ServicesDate, SalesRep

I need to return the Count of CHARGES(ChargesKey) for each SalesRep

Thank you.




  #3  
Old May 25th, 2004, 04:59 AM
Gary B
external usenet poster
 
Posts: n/a
Default trouble with query ADJUSTED!!!!

MASTER
Table: CHARGES
Fields: ChargesKey, ChargesDate

DETAIL
Table: SERVICES
Fields: ServicesKey, ChargesKey, ServicesDate, SalesRep

I need to return the Count of CHARGES(ChargesKey) for each SalesRep

Thank you.


  #4  
Old May 25th, 2004, 05:52 AM
John Vinson
external usenet poster
 
Posts: n/a
Default trouble with query ADJUSTED!!!!

On Mon, 24 May 2004 23:59:12 -0400, "Gary B" wrote:

MASTER
Table: CHARGES
Fields: ChargesKey, ChargesDate

DETAIL
Table: SERVICES
Fields: ServicesKey, ChargesKey, ServicesDate, SalesRep

I need to return the Count of CHARGES(ChargesKey) for each SalesRep

Thank you.


SELECT SalesRep, Count([ChargesKey]) FROM Services GROUP BY SalesRep;

In the query grid, add just the Detail table; add the SalesRep and
ChargesKey fields; click the Greek Sigma icon (like a sideways M), and
change the default GroupBy under ChargesKey to Sum.

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
  #5  
Old May 25th, 2004, 08:25 PM
John Spencer (MVP)
external usenet poster
 
Posts: n/a
Default trouble with query ADJUSTED!!!!

This could be a two-query problem.

Query one.

SELECT Distinct ChargesKey, SalesRep
FROM Detail

Save that as qGetUnique and then

SELECT SalesRep, Count(ChargesKey)
FROM qGetUnique
GROUP BY SalesRep

In later versions of Access you can combine this into one query using a subquery.

Gary B wrote:

MASTER
Table: CHARGES
Fields: ChargesKey, ChargesDate

DETAIL
Table: SERVICES
Fields: ServicesKey, ChargesKey, ServicesDate, SalesRep

I need to return the Count of CHARGES(ChargesKey) for each SalesRep

Thank you.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:30 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.