title: postgres - select one specfic row of another table and store it as column
body: <p>I have a table for timeTracks with the properties startTime and stopTime that are recorded for another table called project.</p>
  
  <p>With the following aggregates I managed to display the count and sum of the amount of tracks that belongs to a project. In case an active Track (one without stopTime) exists, I want 2 additional columns named "activeTrackId" and "activeTrackStartTime".</p>
  
  <pre><code>SLECT
  count(time_track."timeTrackId") AS "timeTracksTotalCount",
  floor(date_part('epoch'::text, sum(time_track."stopTime" - time_track."startTime")))::integer AS "timeTracksTotalDurationInSeconds"
  activeTimeTrackId ??
  activeTimeTrackStartTime ??
  ...
  FROM project
  LEFT JOIN time_track on time_track."fkProjectId" = project."projectId"
  </code></pre>
  
  <p>Technically there can be only one active track at a time. However just in case, it should only select the latest active track, if there a two tracks without stopTime.</p>
  
  <p>How can I that in postgres?</p>