Skip to content

Instantly share code, notes, and snippets.

@stwalkerster
Last active December 19, 2016 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stwalkerster/a667109d8e60252cea82c78ee1e8d206 to your computer and use it in GitHub Desktop.
Save stwalkerster/a667109d8e60252cea82c78ee1e8d206 to your computer and use it in GitHub Desktop.
SELECT
s.jumpsmade,
s.madness,
sys.name AS current_system,
sys.x as curr_x,
sys.y as curr_y,
sys.z as curr_z,
wsys.name AS next_waypoint,
wsys.x as next_x,
wsys.y as next_y,
wsys.z as next_z,
coalesce(inc.incidents, 0) as incidents,
t.jumprange
FROM stwalkerster_ed_explore.session s
INNER JOIN stwalkerster_ed_explore.system sys ON sys.id = s.currentsystem
LEFT JOIN stwalkerster_ed_explore.waypoint w ON w.id = s.nextwaypoint
LEFT JOIN stwalkerster_ed_explore.system wsys ON w.system = wsys.id
LEFT JOIN (
select i.session, sum(i.delta) incidents
from stwalkerster_ed_explore.incident i
inner join stwalkerster_ed_explore.incidenttype it on it.id = i.type
where it.technical = 0
group by i.session
) inc on inc.session = s.id
INNER JOIN stwalkerster_ed_explore.trip t on t.id = s.trip
WHERE s.id = %d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment