I have a dataset which as far as I know is correct. It looks as below.
QuoteStatus Quoteid batchID EffDate Iteration Months Revenue
1 Block Ready 275576 900265 3/1/2019 1 1096 635791
2 Block Ready 275654 900265 3/1/2019 1 1096 635791
3 Sold 275654 900265 3/1/2019 2 1096 635791
However, I have a requirement that when a certain combination of columns put together, each record has to be unique.
From the resultset – I see this as a duplicate record because the combination of QuoteStatus = ‘Block Ready’ and Iteration = ‘1’ repeats more than once. (Even though QuoteID is distinct) I do not want row 1 to appear and I cannot simply remove “QuoteID” from Select statement because I want it to display .
I have tried ROW_NUMBER ( ) OVER ( PARTITION BY QuoteId Order by QuoteID ) as ROW_Partition. However the result is not what i am looking for. I cannot exlclude ROW_Partition = '1' because that would still leave row 2.
QuoteStatus Quoteid batchID EffDate Iteration ROW_Partition Months Revenue
1 Block Ready 275576 900265 3/1/2019 1 1 1096 635791
2 Block Ready 275576 900265 3/1/2019 1 2 1096 635791
3 Block Ready 275576 900265 3/1/2019 1 3 1096 635791
4 Block Ready 275576 900265 3/1/2019 1 4 1096 635791
5 Block Ready 275654 900265 3/1/2019 1 1 1096 635791
6 Block Ready 275654 900265 3/1/2019 1 2 1096 635791
7 Block Ready 275654 900265 3/1/2019 1 3 1096 635791
8 Block Ready 275654 900265 3/1/2019 1 4 1096 635791
9 Sold 275654 900265 3/1/2019 2 5 1096 635791
10 Sold 275654 900265 3/1/2019 2 6 1096 635791
11 Sold 275654 900265 3/1/2019 2 7 1096 635791
12 Sold 275654 900265 3/1/2019 2 8 1096 635791
I want to remove row 1 without explicitly excluding the QuoteID = ‘275576’ because this could happen to many other Quotes.