select * from
(
SELECT ID_number, count( CU_number ) AS CC

FROM MyTable

GROUP BY ID_number
) T
WHERE CC =
(
select max(cc) from
(
SELECT ID_number, count( CU_number ) AS CC

FROM MyTable

GROUP BY ID_number
) T2
)


On Wed, Oct 15, 2008 at 5:08 PM, dave aptiva <[EMAIL PROTECTED]>wrote:

> Hello all,
>
> I'm new to sql and have a question if someone would be kind enough to help
> me with, if I have a table that stores telemarketers by ID_number and the
> customer that they spoke to by CU_number and I use a select statement such
> as;
>
>
>
> SELECT ID_number, count( CU_number )
>
> FROM MyTable
>
> GROUP BY ID_number;
>
>
>
> To find the number of calls that each telemarketer made, this works fine
> but
> how do I then use the results that are returned to find those telemarketers
> that made the most telephone calls ?
>
>
>
> I tried SELECT ID_number, max( count( CU_number ) ) but this causes an
> error
> "#1111 - Invalid use of group function "
>
>
>
> I also tried
>
>
>
> SELECT ID_number, count( CU_number ) AS CC
>
> FROM MyTable
>
> GROUP BY ID_number
>
> WHERE CC = max( CC );
>
>
>
> But this also causes an error, anyone able to offer some pointers ?
>
>
>
> Thanks Dave.
>
>


-- 
I'm a MySQL DBA in china.
More about me just visit here:
http://yueliangdao0608.cublog.cn

Reply via email to