SELECT CEIL(COUNT(tt.id)/12) totalPages, COUNT(tt.id) total
FROM
(
SELECT a.id
FROM
(
SELECT sr2.actor_id, sr2.role_id, '', sr2.actor_views FROM skills_refs sr2 WHERE sr2.role_id = 431
UNION
SELECT crf.aid actor_id, crf.role_id, crf.unresolved_name, crf.actor_views FROM cast_mr_refs crf WHERE crf.role_id = 431
) sr
LEFT JOIN actors a ON a.id = sr.actor_id
LEFT JOIN actors_thumbnails at ON at.id = a.athumbnail_id
LEFT JOIN images i ON i.obj_id = a.id AND i.obj_type='a' AND i.flag = 1
LEFT JOIN urls_real u ON u.objId = a.id AND u.objType = 'a'
WHERE a.lang = 2
GROUP BY a.id
ORDER BY sr.actor_views DESC
) tt