98SUM(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,
99AVG(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,
100(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,
101MIN(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,
108JOIN applications AS a ON(a.session_id = s.id AND a.canceled IS NULL)
109LEFT 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)
110LEFT 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))