Use of Top and Distinct togather

June 5, 2009

If you stuck to the confusion “Can i use top and distinct togather in single query?”

Yes….!! you can do for which you have to trick, i will explain it with both code non working and working.

Non working :

select top(10) distinct can_id from tblCandidate

Working :

select distinct top(10) can_id from tblCandidate

After all its a simple game of changing the sequence of words.

Happy coding.