Here’s rough example of what I need to accomplish for better understanding:
SampleTable
PrimaryKey SpecialCol1 RandomCol SpecialCol2
1 aaa sample1 111
2 aaa sample2 222
3 bbb sample3 444
4 aaa sample4 111
5 ccc sample5 444
6 bbb sample6 444
Final result should look like this:
PrimaryKey SpecialCol1 RandomCol SpecialCol2
--------------------------------------------
2 aaa sample2 222
5 ccc sample5 444
So I just need to select those rows for which combination of SpecialCol1 and SpecialCol2 is unique in that table. I’ve spent a lot of time trying to figure out how it can be done but so far no luck.
Do it in stages.
Find the rows where the combination of columns is unique:
Find the other details for the matching rows: