Re: mysq query without subselects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Blackwater,

On Sep 10, 2004, at 12:39 PM, blackwater dev wrote:

Hello,

I need to grab the max value of all of the data in a table grabbing
the max total for each client.  Example.

T1
id        total      clientid
1          100           111
2          200           111
3          100           112
4          150           112

I need a query that will grab the highest total per clientid (200, and
150) then average them.  My first inclination is to do a subselect

select avg(total) from t1 where t1.total=(select max(total) from t1 t2
where t2.clientid=t1.clientid)

But can't use subselects with mysql....how do I do it??

Yes you can. Check this out and see if all your syntax is correct.

http://dev.mysql.com/doc/mysql/en/Subqueries.html


~Philip

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux