Sorry for the headline, I could not come up with something short and for sure ...
I have an "Updates" table with three columns, text, type created - the text is a text field, typeid is the foreign key from the "type" table, and the created one is a timestamp. The user enters the update and selects the "type" that matches him.
There is a corresponding type table with the columns "id" and "name".
I am trying to get a result with as many rows as in the "type" table, and the last value from updates.text for a particular row in the types. Therefore, if I have 3 types, 3 rows will be returned, one row for each type and the most recent update.text value for the type in question.
Any ideas?
thanks,
John.
sql greatest-n-per-group sql-server-2005
John beynon
source share