Data Set:

Actually I need result set that has all the columns and only single row for each capital letter values among the all same capital letter values.

Result set should be like:


any of three rows.

Actually I have detail records of so many companies in which some where company name are redundant and I have to select single records for each company on the basis of their name. Here I use Capital letters for company name.

I hope you realize the question well.

Please provide a select statement I will be thankful to you all.

  • 1
    Have you tried anything? – JNK Jul 25 '12 at 12:45
  • yeha I tried my basics sql like group by and joins... but not able to find the perfect solution . Thaks to SHARK. He provide the right soulution. – JP Chauhan Jul 25 '12 at 13:36
;with LetterSet as
    select *,
        row_number() over(partition by FirstCol order by SecondCol) as rownum
    from YourLettersTable
from LetterSet
where rownum = 1

Likewise, you could have rownum = 2 for your second result set.

| improve this answer | |
  • > over(partition by FirstCol order by FirstCol) Shark, why not over(partition by FirstCol order by Col2, col3,...) ? I think you'll can get different results between runs. – msi77 Jul 25 '12 at 15:59
  • Ah good point. Error on my part. Fixed, thanks! – Thomas Stringer Jul 25 '12 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.