Sandy said:
Query_Repairer_Totals SQL as requested.
"SELECT qryJob_Details.RepName, qryJob_Details.RepName2,
Sum(qryJob_Details.Total) AS SumOfTotal
FROM qryJob_Details
GROUP BY qryJob_Details.RepName, qryJob_Details.RepName2
HAVING (((qryJob_Details.RepName2) Is Null));
And Query_Repairer_Shared_Totals (not requested but....)
"SELECT qryJob_Details.RepName2, Sum(qryJob_Details.Total) AS
SumOfTotal, Sum([Total]/2) AS [Repairer Share]
FROM qryJob_Details
GROUP BY qryJob_Details.RepName2
HAVING (((qryJob_Details.RepName2) Is Not Null));
Okay. Now I know the names of the source query and the relevant fields it
returns. Here's what I recommend:
1. Create a new query, then switch to SQL view.
2. Delete whatever partial SQL may be In the SQL view window, and paste in
the SQL that you see between the
"start of SQL" and "end of SQL" lines below (not including those boundary
lines):
----- start of SQL -----
SELECT
RepName,
IIf(RepName2 Is Null, [Total], [Total] / 2) As RepTotal
FROM qryJob_Details
UNION ALL
SELECT
RepName2 AS RepName,
([Total] / 2) As RepTotal
FROM qryJob_Details
WHERE RepName2 Is Not Null;
----- end of SQL -----
3. Save that query as "qryRepairerTotalsNormalized", and close it. You
may want to try opening it in datasheet view now, to ensure that I haven't
made a mistake in the SQL.
4. Create another new query. Switch that query to SQL view.
5. Delete whatever partial SQL may be In the SQL view window, and paste in
the SQL that you see between the
"start of SQL" and "end of SQL" lines below (not including those boundary
lines):
----- start of SQL -----
SELECT
RepName,
Sum(qryRepairerTotalsNormalized.RepTotal) As RepTotal
FROM qryRepairerTotalsNormalized
GROUP BY RepName;
----- end of SQL -----
6. Having pasted in the SQL, you can switch this query back to design view
if you like. Save the query as whatever name you like, and test it in
datasheet view to see if it works.
One thing worth noting: you may some some slight oddities due to rounding
errors. We are dividing at the detail level, then summing. Depending on
your needs, it may be necessary to sum, then divide, or else to divide,
then round, then sum. We'll see.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)