SQL Syntx for getting the latest record in a table
Posted on 2012-12-27
I have a table that logs activities with a transfer of data to a third party company, there are multiple transfers of data per sale as the process of finalizing the sale proceeds. The table tracks the individual sale through a unique SalesID and then records each transfer of data via a sequence number and an action code. So the first transfer of data for a particular sale would be sequence number 1 and say action code 1, then later in the process we transfer again and I would then see sequence number 2 and action number 102, then later there may be up to two additional transactions sequenced as 3 and 4 with action codes of 299, 205 etc. I need to be able to pull data from this table for transactions that have reached action code 102 but no further in the process. I know there is a MAX command that takes the biggest number in a table but I'm unsure how to use it in this case.