I have a table that has data like below(sorted by date)
COL_A | COL_B
Item1 | Date1
Item2 | Date1
Item2 | Date2
Item1 | Date3
Item3 | Date3
Now I want a query that will return the first instance of every Item ie the result set should be like;
COL_A | COL_B
Item1 | Date1
Item2 | Date1
Item3 | Date3
How to do this?
If all you need is the first instance of each and no further information then its a simple GROUP BY with MIN:
If you want further information from the table having found the first instance:
You use the derived table to find the first date per Col_A and then join back to the table to retrieve further details