Never use commas in the FROM
clause. Always use proper, explicit, standard, readable JOIN
syntax.
you can fix the problem using GROUP BY
. This allows you to use aggregation functions on columns in the ORDER BY
:
select TOP (1) Error
from tablename v join
tablename j
on v.columname = j.columnname1
group by Error
order by max(v.columnname), max(j.columnname1);
In my experience, this is normally used for date/time columns to order something by the most recent time it appeared.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…