SQLSQL LabPostgreSQL practice
00:0025 / 45
C06Advancedcorrelated subquery

Latest completed run by source

Return run_id, customer_id, source_name, status, and started_at for runs whose started_at is the latest completed run for that same customer and source. Exclude running rows. Sort by customer_id, then source_name.

Data available

Use this table

1 table
Table 1

pipeline_runs

Data ingestion jobs from four upstream sources.

  • run_idintegerPK
  • customer_idintegerFK
  • source_nametext
  • statustext
  • started_attimestamptz
  • completed_attimestamptzNULL
  • records_ininteger
  • records_outintegerNULL
Query editor

PostgreSQL

Run query
Result stream

Output

Run your query to inspect its result.
Contextual coach

Ask about this attempt

Run or check a query first. The coach only comments on a real error or grader mismatch.

Field notes

Hints & explanation

Try to solve it cold. Two progressive hints are available.