Try the below:
Create Table EmailDir(emailid varchar(50),Ename varchar(100), Edob date)
Insert into EmailDir Values('harish123@gmail.com','Harish Salve','10-15-1989'),
('navink87@hotmail.com','Navin Keddy','02-17-1987'),
('harish124@gmail.com','Harish Salve','10-15-1989')
;With cte as
(
Select EmailID,EName,Edob,Row_Number()Over(partition by EName Order by EmailID asc) Rn
From EmailDir
) Select * From cte where rn=1
Drop table EmailDir
No comments:
Post a Comment