Using SUM with a subquery
- From: vespaboy <danielevans@xxxxxxxxx>
- Date: 4 May 2007 03:54:21 -0700
the following query returns the error:
Cannot perform an aggregate function on an expression containing an
aggregate or a subquery.
Any ideas how to make it work? It's the second SUJ causing the error
and i can see why but can't work out a solution.
thanks in advance
dan
SELECT SUM(CO2 * (NormalMileage *2)), tbluser.userid,SUM((SELECT CO2
FROM tblTravelMode WHERE ModeCode = tblUser.TravelModeCode))
FROM tblTravelDiary
INNER JOIN tblTravelMode
ON tblTravelDiary.TravelModeCode = tblTravelMode.ModeCode
INNER JOIN tblUser ON
tblTravelDiary.UserId = tblUser.UserId
GROUP BY tblUser.UserId
.
- Follow-Ups:
- Re: Using SUM with a subquery
- From: Ed Murphy
- Re: Using SUM with a subquery
- Prev by Date: Updating production from backoffice
- Next by Date: Re: Using SUM with a subquery
- Previous by thread: Updating production from backoffice
- Next by thread: Re: Using SUM with a subquery
- Index(es):
Relevant Pages
|