query problem

J

JohnE

I am putting a query together that will eventually be for a report. But
getting lost in the process. I have 3 tables that are coming together to
form the query. A client can have many different areas that has revenue
attached to it. In the query/report only a field needs to show the sum of
the different areas, not each item. The different items would be totalled.
There is also another field that singles out only one item, of which, only
the revenue needs to be totalled for it. Below is what I have so far. It
does work, to a point. I am not able to get only the sum to work to display
in a field. Some of the fields are marked not to show.

SELECT usrtblClientInformation.ClientName,
usrtblClientInformation.ClientServicesPerson,
usrtblClientInformation.ClientRenewalDate,
usrtblAccountManagementUpdate.ProfitabilityMargin,
usrtblAccountManagementUpdate.RenewalStatus,
usrtblAccountManagementUpdate.RenewalIncrease,
usrtblAccountManagementUpdate.SpecialtyItemUpdateNote,
usrtblAccountManagementUpdate.SpecialtyItemTopic,
usrtblEstimatedRevenue.RevenueItem AS Revenue,
Sum(usrtblEstimatedRevenue.EstimatedRevenueAmount) AS
SumOfEstimatedRevenueAmount

FROM (usrtblClientInformation INNER JOIN usrtblAccountManagementUpdate ON
usrtblClientInformation.ClientCode =
usrtblAccountManagementUpdate.ClientCode)
INNER JOIN usrtblEstimatedRevenue ON usrtblClientInformation.ClientCode =
usrtblEstimatedRevenue.ClientCode

GROUP BY usrtblClientInformation.ClientName,
usrtblClientInformation.ClientServicesPerson,
usrtblClientInformation.ClientRenewalDate,
usrtblAccountManagementUpdate.ProfitabilityMargin,
usrtblAccountManagementUpdate.RenewalStatus,
usrtblAccountManagementUpdate.RenewalIncrease,
usrtblAccountManagementUpdate.SpecialtyItemUpdateNote,
usrtblAccountManagementUpdate.SpecialtyItemTopic,
usrtblEstimatedRevenue.RevenueItem,
usrtblEstimatedRevenue.RevenueYear

HAVING (((usrtblAccountManagementUpdate.SpecialtyItemTopic)="Renewal") AND
((usrtblEstimatedRevenue.RevenueYear)="2005"));

Thanks to anyone who responds.
*** John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top