I have a table Table like this:
ColumnA (VARCHAR)|ColumnB (VARCHAR)|ColumnC (VARCHAR)|ColumnD (DATE)
A1 B1 C1 2012-12-06
A1 B1 C1 2012-12-12
A2 B2 C2 2012-12-07
A2 B2 C2 2012-12-09
I want to select only the 1st occurrence combined to ColumnA-ColumnB-ColumnC so the result will be something like this:
A1 | B1 | C1 | 2012-12-06
A2 | B2 | C2 | 2012-12-07
You can use an aggregate function on the Date column and the group by the rest:
See SQL Fiddle with Demo
Or you can use
row_number():See SQL Fiddle with Demo