如何从" nb"中获取最大值?柱&#34 ;?

时间:2016-10-18 19:32:09

标签: php mysql count max

以下是我获得第一个结果的方法:

SELECT PageName, COUNT(DISTINCT Ip) as nb FROM statistique INNER JOIN visite ON statistique.Id = visite.IdPage GROUP BY statistique.Id;

这就是我得到的:PageName nb /edsa-PHP/index.php 1 /eds -PHP / test2.php 1 /PHP/index.php 3 /PHP/test2.php 1

PageName              nb
/edsa-PHP/index.php   1
/edsa-PHP/test2.php   1
/PHP/index.php        3
/PHP/test2.php        1

我认为这可以获得计数的最大值:

SELECT MAX(nb) FROM (SELECT PageName, COUNT(DISTINCT Ip) as nb FROM statistique INNER JOIN visite ON statistique.Id = visite.IdPage GROUP BY PageName) AS t;  

0 个答案:

没有答案