SELECT c.customerID,CONCAT(...) ,COUNT(i.customerID) as Num
FROM customers c,invoice i WHERE c.customerID = i.customerID GROUP BY
c.customerID ORDER BY Num DESC LIMIT 0,10 ;

Sorry, solved my own difficulty.

On Tue, 20 Aug 2002, Quinten Steenhuis wrote:

> Date: Tue, 20 Aug 2002 13:01:17 -0400 (EDT)
> From: Quinten Steenhuis <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: ordering by frequency
>
>
> I have a simple query that I must have framed incorrectly, because MySQL
> returns an error:
>
> SELECT c.customerID,CONCAT(...) as Cust FROM customers c,invoice i WHERE
> c.customerID = i.customerID ORDER BY COUNT(i.customerID) LIMIT 0,10;
>
> This tells me ERROR 1111: Invalid use of group function
>
> How can I get the ordering that I want? My goal is to select my ten most
> frequent customers. I tried adding the COUNT() clause into the column
> list, but then MySQL wanted a GROUP BY clause. When I added a group by
> clause, I couldn't keep the ORDER BY clause...
> Can anyone help?
>
> Thanks, this is much appreciated, since I know I have a pretty simple
> problem.
>
> Quinten
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to