"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:ezQO3ctuEHA.3416@TK2MSFTNGP09.phx.gbl...
> SELECT
>
> [donation].[Month] AS Month,
> [Donation].[Group] as group1,
> SUM([donation].Amount) AS Qty,
> SUM([donation_1].Amount) AS donation_amount,
> [donation_1].Type,
> SUM([donation_1].Amount) / SUM([donation].Amount) AS donation_average
>
> FROM ...
>
>
> --
> Adam Machanic
> SQL Server MVP
>
http://www.sqljunkies.com/weblog/amachanic > --
>
>
> "Bogogboy" <bogoboy@NOSPAMyahoo.co.uk> wrote in message
> news:e66YLTtuEHA.3376@TK2MSFTNGP12.phx.gbl...
> > Hi Hope someone can point me in the right direction
> >
> > I have a query that produces 2 sums
> > QTY and Donation_amount
> > I am trying to work out the average donation
> > therefore I would like to sum (donation_amount/QTY)
> > How Can I do this in the query
> > when I try adding this in the error message is invalid column name for
> > these.
> >
> > I take it this is due to the query not producing the columns yet.
> >
> > any help appreciated
> > here is the query that produces the 2 sums
> > Thanks in advance
> >
> > Bogo.
> >
> >
> > SELECT
> >
> > [donation].[Month] AS Month,
> > [Donation].[Group] as group1,
> > SUM([donation].Amount) AS Qty,
> > SUM([donation_1].Amount) AS donation_amount,
> > [donation_1].Type
> >
> > FROM
> >
> > [donation] INNER JOIN
> > [donation] [donation_1]
> > ON [donation].[Month] = [donation_1].[Month]
> > AND [donation].[branch] = [donation_1].[branch] AND
> > [donation].Sort = [donation_1].Sort AND [donation].[Group] =
> > [donation_1].[Group]
> >
> > WHERE
> >
> > ([donation_1].Type <> N'numbers')
> > AND
> > ([donation].Type = N'numbers')
> > AND
> > ([donation].[Month] = CONVERT(DATETIME, '2004-07-01 00:00:00', 102))
> >
> > GROUP BY
> >
> > [donation].[Month],
> > [donation].[Group],
> > [donation_1].[Group],
> > [donation_1].Type,
> >
> >
>
>