" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi
Sometimes it is seen if the beginners are getting some duplicates in their resultset then they are using DISTINCT. But this has its own disadvantages.
This can be verified by looking through the execution plan in sql server management studio.This comes with different alternatives also.
SELECT [Name],row_number( ) OVER
(PARTITION BY [Name]) rownumber
FROM [dipali_Table2]) t
WHERE rownumber = 1
NB: row_number() will not work in sql server 2000.Works for 2005 onwards.
NB: If we have some situation that we will be getting resultset of one column then it is wise to use.
Mail (will not be published) (required)
Enter Captcha Code *
− 5 = one
Burn Ignorance is a knowledge initiative by Mindfire Solutions
Subscribe to our mailing list to get the updates to your email inbox...