SELECT MIN(u.lau_date) first_update, p.pid, p.proj_name, l.lid, l.loc_name, l.loc_status
FROM now_proj p
JOIN now_plr pl ON pl.pid=p.pid
JOIN now_loc l ON l.lid=pl.lid
JOIN now_lau u ON u.lid=l.lid
WHERE p.proj_records=1
AND u.lau_date < '2017-11-23'
GROUP BY l.lid
ORDER BY p.pid, l.lid
SELECT MIN(u.lau_date) first_update, p.pid, p.proj_name, l.lid, l.loc_name, l.loc_status FROM now_proj p JOIN now_plr pl ON pl.pid=p.pid JOIN now_loc l ON l.lid=pl.lid JOIN now_lau u ON u.lid=l.lid WHERE p.proj_records=1 AND u.lau_date < '2017-11-23' GROUP BY l.lid ORDER BY p.pid, l.lid