Consider the following table:
primaryKey id activity template creator created
1 1 3 5 x 2011-10-13
2 2 4 2 y 2011-10-15
3 2 4 7 z 2011-10-24
4 2 4 7 u 2011-10-29
From here I want to retrieve the records which are having unique combinations for id
, activity
and template
. In case there are two or more unique combinations of those fields are exists I want to take the first one of them.
As an example for above table data the output that I need is
primaryKey id activity template creator created
1 1 3 5 x 2011-10-13
2 2 4 2 y 2011-10-15
3 2 4 7 z 2011-10-24
(since record 3 and 4 are having same combination I want to take just the record 3 because it is the first occurance)
Can I do this using a single SQL statement?