- LEFT OUTER JOIN (SELECT DISTINCT ON (planet) planet,tick from scans where type = 'News' ORDER BY planet,tick DESC) n USING (planet)
- LEFT OUTER JOIN (SELECT DISTINCT name,eta,tick,sender,target,mission,ingal FROM intel WHERE amount IS NULL) i ON i.sender = u.planet
- LEFT OUTER JOIN current_planet_stats t ON i.target = t.id
- LEFT OUTER JOIN (SELECT rt.id,planet,tick FROM raids r
- JOIN raid_targets rt ON r.id = rt.raid) rt ON rt.planet = i.target
- AND (rt.tick + 12) > i.tick AND rt.tick <= i.tick
+ LEFT OUTER JOIN (SELECT DISTINCT ON (pid) pid,tick from scans where type = 'News' ORDER BY pid,tick DESC) n USING (pid)
+ LEFT OUTER JOIN (SELECT DISTINCT name,eta,tick,sender,target,mission,ingal FROM intel WHERE amount IS NULL) i ON i.sender = u.pid
+ LEFT OUTER JOIN current_planet_stats t ON i.target = t.pid
+ LEFT OUTER JOIN (SELECT rt.id,pid,tick FROM raids r
+ JOIN raid_targets rt ON r.id = rt.raid) rt ON rt.pid = i.target
+ AND (rt.tick + 12) > i.tick AND rt.tick <= i.tick