There is no difference in your delete.
However, the FROM
clause is a fully functional from clause, so you can use it with JOIN
. For instance:
delete t
from t join
(select min(id) as minid
from t
group by grp
) tt
on t.id = tt.minid;
This would delete the record with the minimum id for each grp
value. The alias after the delete
is needed to specify which table to delete from (although in this case, deleting from an aggregation result is not allowed).
Note: This query is for illustrative purposes. There is nothing wrong with the query, but it is not how I would actually write such a query in SQL Server.