atc: max in flight query should be distinct
atc: max in flight query should be distinct

I previously removed the distinct option within the get next pending
build query because I thought it was not needed. Turns out I forgot that
jobs_serial_groups table that is joined within the query can have
multiple rows for the same job so the distinct is needed to make sure
the query only returns back on row for a build. I added back the
distinct to the query but had to make it a subquery because of the new
order by restrictions.

[#5475]

Signed-off-by: Clara Fu <d5c8bdbc15689555c92563892e959c79b3fc425f@pivotal.io>

concourse/concourse,concourse/concourse,concourse/concourse,concourse/concourse,concourse/concourse