Re: limit 5 iclouding also all the equals value with the 5th

From: Kostas Konstantinidis <kost36_at_gmail.com>
Date: Sat, 21 Oct 2017 02:39:15 -0700 (PDT)
Message-ID: <ef6add9f-a31e-4d25-a282-90fe2dffe0af_at_googlegroups.com>


Dear all,
The final solution based on Peter's Browly from mysql forums help, in case anybody will need it in the future...

The first query (`fnl`) counts the total director's movies

SELECT
`t_people`.`person` AS `person`,
COUNT(`st_peoplefilms`.`ID_films`) AS `total` FROM
(`t_people`
JOIN `st_peoplefilms` ON ((`t_people`.`ID_person` = `st_peoplefilms`.`ID_person`))) GROUP BY `t_people`.`person` , `st_peoplefilms`.`ID_idiotita` , `t_people`.`sex` HAVING ((`st_peoplefilms`.`ID_idiotita` = 29) AND (`t_people`.`sex` = 1))
ORDER BY COUNT(`st_peoplefilms`.`ID_films`) DESC

Then I wrote another one based on `fnl` which makes the trip like:

GROUP_CONCAT('<a href="./index.php/search-movies/peoplefilm?person=', `fnl`.`person`,
'">',
`fnl`.`person`,
'</a>'
SEPARATOR ', ') AS `Director`,
`fnl`.`total` AS `Total movies`
FROM
`fnl`
GROUP BY `fnl`.`total`
ORDER BY `fnl`.`total` DESC
LIMIT 5 So, the final query returns data as I just need it e.g.

+--------------------------+----------------+

| Director | Total movies |
+--------------------------+----------------+
| Kostas | 100 |
| George | 95 |
| John | 70 |
| Peter | 68 |
| Dick, Tom, Jack, 'n...' | 65 |
+-------------------------------------------+

Many many thanks Received on Sat Oct 21 2017 - 11:39:15 CEST

Original text of this message