when the field is a duplicate
There are duplicates of a specific field in a sql database. If the selected row has a duplicate in the code field then I want to select one of them as 'a' as field2 and one of them as 'b' as field2.
something like: case when the code field is a duplicate in the database, then select one of the duplicates as 'a' and the other as 'b' as field2 . there is no primary key in the table.
What would be the best way to accomplish this?
Thank you.
Re: when the field is a duplicate
How is your table structured? From reading your post, it appears you want the duplicate records to get sorted in two different buckets. What happens if there's a third record with the same column values?
Re: when the field is a duplicate
The first value should be 'a' and all the rest of duplicate values(second, third...) should be 'b'.
Thank you.