Error:

ERROR: syntax error at or near ")" LINE 3: ) as sx GROUP BY tabla,nombre,id ORDER BY cuenta DESC,tabla... ^
SELECT count(*) as cuenta, tabla, nombre, id FROM ( ) as sx GROUP BY tabla,nombre,id ORDER BY cuenta DESC,tabla,nombre;