I'm trying to get the latest date in a query using 2 tables with a left join. Can someone explain the difference about when to use the Max function vs. the First or Top 1 when sorting by descending order?
MAX gives you the largest value (numeric) or the latest value (dates) or the one furthest down the alphabet (text values) for a field. It does not depend on the ordering of the records but it does depend on their filtering and grouping.
FIRST gives you the first value retrieved (after sorting by Order By) for a field. It may or may not be the MIN or MAX value. It does depends on the ordering, filtering and grouping.
TOP 1 gives you the first record after the resultant recordset is ordered. It is a record selector, not a specific field selector. It does depends on the ordering, filtering but not the grouping of records.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.