Retrieval of the latest date set of information in SQL database
Posted on 2010-11-09
Hi, I am creating a Crystal report and I need to select information between two tables.
One table holds all the data items (TableA) that I want to report on. I then need to retrieve Audit history from another table (tableB).
In my cystal report I want to compare beside each other the new value and the last history item.
The problem is that I get many rows of the same data with the last part of the tableB showing all the times the values have been changed.
I would like to create a select statement that would choose the latest time stamped item, so that only one row show for each of the tableA items. The problem is that the TableA may be null or an item or it could have 1 to many values.
What is the best way to only select the last value from table B for each of Table A items? I am sure there are key words for this but I haven't done SQL select statments for a few years now.