45SUM(IF(a3.id IS NOT NULL,1/ABS(DATEDIFF(ADDDATE(b.date,INTERVAL IF(b.slot_id =4,1,0)DAY),ADDDATE(s3.date,INTERVAL IF(s3.slot_id =4,1,0)DAY))),0))AS g_score,
59SUM(IF(a2.id IS NOT NULL,1/ABS(DATEDIFF(ADDDATE(s.date,INTERVAL IF(s.slot_id =4,1,0)DAY),ADDDATE(s2.date,INTERVAL IF(s2.slot_id =4,1,0)DAY))),0))AS l_score,
60AVG(IF(a2.id IS NOT NULL AND s2.temperature IS NOT NULL AND s2.rainfall IS NOT NULL, s2.temperature/(1+s2.rainfall),NULL))AS l_tr_ratio,
61(SUM(IF(a2.id IS NOT NULL AND s2.premium =1,1,0))+1)/(SUM(IF(a2.id IS NOT NULL AND s2.premium =0,1,0))+1)AS l_pn_ratio,
62MIN(IF(a2.id IS NOT NULL,DATEDIFF(ADDDATE(s.date,INTERVAL IF(s.slot_id =4,1,0)DAY),ADDDATE(s2.date,INTERVAL IF(s2.slot_id =4,1,0)DAY)),NULL))AS l_previous,
69JOIN applications AS a ON(a.session_id = s.id AND a.canceled IS NULL)
70LEFT JOIN sessions AS s2 ON(s2.id!= s.id AND s2.location_id = s.location_id AND s2.slot_id IN(2,3)AND s2.application_id IS NOT NULL AND s2.locked IS NULL AND s2.date> s.date-INTERVAL1YEAR)
71LEFT JOIN applications AS a2 ON(a2.id= s2.application_id AND a2.user_id = a.user_id AND(a2.canceled IS NULL ORTIMESTAMPDIFF(DAY, a2.canceled,ADDDATE(ADDTIME(s2.date, s2.begin),INTERVAL IF(s2.slot_id =4,1,0)DAY)) <1))
83LEFT JOIN sessions AS s4 ON(s4.id!= c.session_id AND s4.location_id = c.location_id AND s4.application_id IS NOT NULL AND s4.locked IS NULL AND s4.date> c.date-INTERVAL1YEAR)
84LEFT JOIN applications AS a4 ON(a4.id= s4.application_id AND a4.user_id != c.user_id AND(a4.canceled IS NULL ORTIMESTAMPDIFF(DAY, a4.canceled,ADDDATE(ADDTIME(s4.date, s4.begin),INTERVAL IF(s4.slot_id =4,1,0)DAY)) <1))