All Forums Database
Vga 12 posts Joined 02/12
04 Sep 2014
Selecting only non duplicate values from a set of columns

Requiement:- I need to remove duplicate from the data set below. The selection criteria for duplicate selection is only the first three columns i.e. C1, C2 & C3.

 

While selecting the data from source table, the last row should be retained after removing duplicates.

 

 

C1|C2|C3|C4|C5|C6

1|2|3|8|9|10

1|2|3|7|8|6

1|2|3|7|8|6

6|4|0|3|5|7

5|2|8|1|3|5

5|2|8|4|9|7

 

If we consider the above set of data in the same order, expected output can be:

 

C1|C2|C3|C4|C5|C6

1|2|3|7|8|6

6|4|0|3|5|7

5|2|8|4|9|7

 

Imp note:- While selecting the source data, no other column should be used in the select statement other than C1/C2/C3 to get the desired output.

 

Thanks,

VGA

Raja_KT 1246 posts Joined 07/09
04 Sep 2014

try this:
select c1,c2,c3,c4,c5,c6 from your_table qualify row_number() over(partition by c1,c2,c3 order by c6 desc) =1

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

You must sign in to leave a comment.