This logic:
select billing_invoice.id
from . . .
group by billing_invoice.id
order by billing_invoice.timestamp_created desc
should return an error. Why? The order by
is executed after the aggregation and there is no billing_invoice.timestamp_created
after the GROUP BY
.
This code should be generating a syntax error. And it would in the more recent versions of MySQL (with the default settings).
You need an aggregation function:
order by max(billing_invoice.timestamp_created) desc
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…