Prueba esto;)
Consulta 1 :
select t1.*, t2.userCnt
from `posts` t1
inner join (
select max(`ID`) as `ID`, `user`, count(1) as userCnt
from `posts`
where `user` != '1'
and `post_type` = 'custom'
group by `user`
) t2 on t1.`ID` = t2.`ID` and t1.`user` = t2.`user`
order by t1.`ID` desc limit 4
Compruebe este SqlFiddle Resultados :
| ID | user | Date | title | status | post_type | userCnt |
|------|------|---------------------|-------|-----------|-----------|---------|
| 2783 | 5 | 2016-05-24 11:24:08 | Title | published | custom | 2 |
| 2759 | 3 | 2016-05-07 14:00:22 | Title | published | custom | 3 |
| 2757 | 12 | 2016-05-02 12:41:00 | Title | published | custom | 2 |
| 2683 | 15 | 2016-04-22 20:27:45 | Title | published | custom | 2 |
Subconsulta t2
obtendrá el ID
máximo en cada usuario cuando user != '1' and post_type = 'custom'
, luego inner join
t1 con t2 en t1.ID = t2.ID and t1.user = t2.user
nos dará un registro que tiene un máximo de ID
por cada user
en la tabla post
. Me gusta:"2783", "2759", "2757", "2683", "2681", "2652", "2630", "2617", "2596", "2215".
Y por último con order by
y limit
, por supuesto, puede obtener "2783", "2759", "2757", "2683". Espero no haberme equivocado en tu pregunta.