There are 2 tables (subj, rait). It is necessary to derive the medial value in subjects, that is
subject_id, subject name, medial value for the given subject.
How to bring the medial in subjects without the name of the object - I understood, but I don’t understand how to shove the name of the object there, at least kill me.
SELECT `subject_id`,(MAX(`value`)+MIN(`value`))/2 FROM (SELECT cs.`subject_id`,`value` FROM (SELECT subject_id,value, ( SELECT COUNT(1) FROM rating WHERE `value`<o.`value` AND `subject_id`=o.`subject_id` ) as ls , ( SELECT COUNT(1) FROM rating WHERE `value`<=o.`value` AND `subject_id`=o.`subject_id` ) as lse FROM rating o ) cs JOIN (SELECT `subject_id`,COUNT(1)*.5 as cn FROM rating GROUP BY `subject_id` ) cc ON cs.`subject_id`=cc.`subject_id` WHERE cn between ls and lse ) AS medians GROUP BY `subject_id` 
