1
I have the following table:
imovel
ano | id | item | valor
Records:
2000| 1 | 201 | null
2001| 1 | 211 | 10
2002| 1 | 202 | null
2000| 2 | 201 | null
2001| 2 | 221 | 17
2002| 2 | 211 | 14
2000| 3 | 201 | null
What I need is that each id always returns only the last record filtered by the last year and the item that will filter, and the first 2 characters of the item references the same and the last character references the item option (ex: The query of item 201 should return 2 records referring to id 2 and 3. id 1 should not be returned because its last item update was made in 2002 where item 20 is with option 2).
which lines would return in your sampling ?
– Marco Souza
Possible duplicate of Get only last query sql server record
– Oralista de Sistemas