Never mind, sorting by Quantity did it.  I was sure I had already tried this
with no results but hey...

Sorry to waste all of your time.

--
Jay

> -----Original Message-----
> From: James Smith [mailto:[EMAIL PROTECTED]
> Sent: 04 August 2004 13:34
> To: CF-Talk
> Subject: Sorting by aggregate functions
>
> I have a situation where I need to sort a query by an
> aggregate function,
> ie:
>
> SELECT   d.ItemID, d.Title, sum(i.Quantity) AS Quantity
> FROM     SomeTables
> GROUP BY d.ItemID, d.Title
> ORDER BY sum(i.Quantity)
>
> However this does not work and tells me I have an "Invalid
> use of group function".  So far the only way I have been able
> to do it is to remove the ORDER BY completely and then do a
> query of this query and order by Quantity.
>
> This seems silly and there must be a better way but much
> searching of the DB docs has revealed nothing.  Anyone know
> how to do this?
>
> Probably should have said earlier that the DB is MySQL (4.1.3)
>
> --
> James Smith
> [EMAIL PROTECTED]
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to