Hi. I am using the CB plugin from the JLexReview component to able the user to make reviews and ratings. The new CB plug_cbprofilebook adds the cb_pb_profile_rating to the com_profiler table. That opens the opportunity to me to create a CB List ordered by that field but I need to update this field with the JLexReview data.

With the JLexReview support help this is the needed query:

UPDATE scr_comprofiler c
SET cb_pb_profile_rating =
( SELECT (rating.sum_rate/rating.count_orate) as avgrate
FROM scr_jlexreview r
INNER JOIN scr_users u ON u.id=r.object_id
LEFT JOIN (
SELECT object, object_id, CONCAT(object,'_',object_id) kk,
SUM(CASE WHEN review_rate>0 THEN 1 ELSE 0 END) count_orate,
SUM(review_rate) sum_rate
FROM scr_jlexreview
WHERE review_rate<= 5 AND published=1 AND object='com_comprofiler'
GROUP BY kk ) AS rating ON rating.object_id=r.object_id
WHERE r.published=1 AND rating.count_orate>0 AND c.user_id=r.object_id
GROUP BY r.object_id
ORDER BY avgrate DESC )
WHERE c.approved>0

Then my question:
Where it is best to update the new cb_pb_profile_rating comprofiler table field in order to get an ordered List by this field?. How could I do that?. Any suggestions?.
Thanks in advance.
Octavio.