I'm trying to calculate the normalized average cost by area.
SELECT a.[market]
,sum(a.[cost]) as total_cost
,sum(a.[services]) as total_service
,(sum(a.[cost])/sum(a.[services]))/subquery.averagecost_national as Normalized_Average_Cost
FROM [Table A] a,
[Table B] b,
(SELECT
sum(a.[cost])/sum(a.[services]) as averagecost_national
FROM [Table A] a,
[Table B] b
where a.[ID] = b.[ID]) as subquery
where (a.[ID]) = b.[ID]
group by a.[market]
SELECT a.[market]
,sum(a.[cost]) as total_cost
,sum(a.[services]) as total_service
,(sum(a.[cost])/sum(a.[services]))/subquery.averagecost_national as Normalized_Average_Cost
FROM [Table A] a,
[Table B] b,
(SELECT
sum(a.[cost])/sum(a.[services]) as averagecost_national
FROM [Table A] a,
[Table B] b
where a.[ID] = b.[ID]) as subquery
where (a.[ID]) = b.[ID]
group by a.[market]