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

From: Jerry Stuckle <jstucklex_at_attglobal.net>
Date: Sat, 14 Oct 2017 15:57:52 -0400
Message-ID: <ortq7t$4d8$1_at_jstuckle.eternal-september.org>


On 10/14/2017 12:04 PM, Kostas Konstantinidis wrote:
> Dear The Natural Pholisopher and Jerry,
>
> while trying to make all of your suggestions I got a new idea not really so complicate...
> To work with GROUP_CONCAT on persons and the total of films for each record and then limit to n
> So i used
>
> SELECT
> GROUP_CONCAT(`st_peoplefilms`.`ID_person`
> SEPARATOR ', ') AS `person`,
> COUNT(st_peoplefilms`.`ID_films`) AS `total`
> FROM
> `st_peoplefilms`
> WHERE
> (`st_peoplefilms`.`ID_idiotita` = 29)
> GROUP BY `st_peoplefilms`.`ID_person`
> ORDER BY `total` DESC
> LIMIT 5
>
> it should return
> person CountOfID_films
> 1 100
> 2 95
> 3 70
> 4 68
> 5, 6, 7, 8 65
>
> but it returns just the same as my 1st topic
>
> thank's
>

Yes, which is why I didn't suggest it.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex_at_attglobal.net
==================
Received on Sat Oct 14 2017 - 21:57:52 CEST

Original text of this message