Fix sorting jobs by time_submitted and state

After joining with the tasks table multiple times, the state and
time_submitted columns become ambiguous, which makes sorting by them a
bit more involved.