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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sum calculation problem

Status
Not open for further replies.

cvaccess

Technical User
Jun 26, 2002
55
US
I think my problem is the way they are linked but am not sure. My query does not combine the same tp and date totals. For example, Scrub_date is 6/24/02 and tp_num is RHA. This date and tp is listed twice with different totals, 300 and 1. I want it to combine these as one. So it would show one output of this tp and date being:scrub_date 6/24/02, tp_num RHA and total 301. Here is the query:

SELECT DISTINCTROW pend_summary.TP_NUM AS TP, pend_summary.SCRUB_DATE AS ScrubDate, Sum(pend_summary.TOTAL) AS Pended, Sum(indiv_tp_sub.CLAIM_SUB) AS Accept, (Sum([pend_summary].[total])/Sum([indiv_tp_sub].[claim_sub])) AS [Pend %]
FROM pend_summary INNER JOIN indiv_tp_sub ON (pend_summary.SCRUB_DATE = indiv_tp_sub.SCRUB_DATE) AND (pend_summary.TP_NUM = indiv_tp_sub.CHILD_TP)
WHERE (((pend_summary.SCRUB_DATE) Between [Enter Starting Create Date:] And [Enter Ending Create Date:]) AND ((pend_summary.TP_NUM)=[indiv_tp_sub].[child_tp]))
GROUP BY pend_summary.TP_NUM, pend_summary.SCRUB_DATE, indiv_tp_sub.CLAIM_SUB,indiv_tp_sub.CHILD_TP
HAVING ((((((Sum([pend_summary].[total])/Sum([indiv_tp_sub].[claim_sub]))*100)>[Enter Pend % as a whole number]))<>0))
ORDER BY pend_summary.TP_NUM, (Sum([pend_summary].[total])/Sum([indiv_tp_sub].[claim_sub])*100) DESC;

Anyone, please help me.

Thank you.
 
First we need to see what the tables look like, and what you are trying to do. It's too hard to read the Access generated SQL. Let me ask you this though, can a date appear more than once? Or are the dates distinct?
 
Yes, a date can appear more than once. I want it to combine same dates and TP into one total. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top