How to get the MAX row
I need to fetch the "latest" row for certain conditions in my
tkhist1 table. Tickets are bound to
LocationID, and I need to select one row for
DISTINCT values of both of those columns.
Multiple rows may share the same
LocationID though, they are additionally defined by a UniqueID column. I need to select a single row for each combination of TicketNo and LocationID,
SELECTING the row with the single highest
UniqueID value. I do not need Unique ID in my
The following query selects some of the information I need, but it does not only grab one row per
UniqueID. If a row has different values for
FreightPay (or any other column) it will be SELECTED as a new row.
I need a single row for each distinct pair of
LocationID, selecting only information from the highest value (