Julie F
2007-10-31 10:34:28 UTC
Server: Msg 207, Level 16, State 3, Line 12
Invalid column name 'TotalUsage'.
This is the query:
SELECT r.endPointId, SUM(r.usage) as TotalUsage, s.revenueClass, m.multiplier
FROM serviceLocations s, Meters m, Readings r, EndPoints e
WHERE r.endPointId = e.endPointID and e.meterID = m.meterID
and s.serviceLocationId=m.serviceLocationId and s.revenueClass Like '__1'
and (readingDate > '09/29/2007') AND (readingDate < '10/31/2007')
and (quality = 0) and billingCycleId = '3'
GROUP BY r.endPointId, s.revenueClass, m.multiplier
Having sum(r.usage) > 0
Order by s.revenueClass
select SUM(TotalUsage);