Jane,
Thanks, that worked fine, but I suspect the performance probably isn't too
good. I now need to total the rows across and show it on the right like
this:
Expr1 Rent Fees Council Electric Gas
Misc Rates Repairs Supplied TOTALS
Alderm83 £815.00
£815.00
Alles170
£1,384.80 -£235.00 -£86.92 -£380.00 -£193.88 £489.00
Bede9 £786.70
£786.70
Benson £675.00
£675.00
Blythe48 £725.00
£725.00
BlytheR8
-£44.00 £431.00
Bolin134 £584.00 -£6.45 -£50.00 -£107.00
£420.55
I can't get the sum to work correctly across the rows.
SELECT
IIf([type]=1,Left(Trim([Property]),Len(Trim([Property]))-2),Trim([Property])
) AS Expr1, Sum([Sub Consol2].Council) AS Council, Sum([Sub
Consol2].Electric) AS Electric, Sum([Sub Consol2].Fees) AS Fees, Sum([Sub
Consol2].Gas) AS Gas, Sum([Sub Consol2].Misc) AS Misc, Sum([Sub
Consol2].Rates) AS Rates, Sum([Sub Consol2].Rent) AS Rent, Sum([Sub
Consol2].Repairs) AS Repairs, Sum([Sub Consol2].Supplied) AS
Supplied,[Council]+[Rent]+[Fees] AS Expr2
FROM [Sub Consol2] INNER JOIN Property ON [Sub Consol2].Property =
Property.Code
GROUP BY
IIf([type]=1,Left(Trim([Property]),Len(Trim([Property]))-2),Trim([Property])
), [Council]+[Rent]+[Fees];
Summing only three fields as part of the select (as above) does not give the
right answer.
Suggestions?
Barry.
Jane said:
I would suggest first creating a query to get a rollup title for the like
items. For example, assuming that all of your items in column A are 8
characters plus the extra stuff, a rollup function could be =Left([column
a],8). Put all of the rest of the columns in the query as well.
Then, create a new query based on the last one, include your new column
instead of column A, along with all the other columns. Do sums, group by the
rollup column and sum the rest.
Hope this helps,
Jane
Microsoft News said:
I am trying to combine the Alles170* rows into one row that shows the totals
for each column.
ColA ColB ColC ColD ColE ColF
Alles170 -£86.92 -£380.00 -£193.88
Alles170-2 -£58.75
£280.00
Alles170-3 -£58.75
£280.00
Alles170-5 -£58.75
£300.00
Alles170-6 -£58.75
£524.80
I want this:
ColA ColB ColC ColD ColE ColF
Alles170 -£86.92 -£235.00 -£380.00 -£193.88 £1,384.80
Can anyone help with the SQL?