Hi All,
Please find the below solution
Thanks & Regards,
Mathi.
USE [MASTER]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[testing_new](
[id] [int] NULL,
[pid] [int] NULL
) ON [PRIMARY]
GO
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (1, 100)
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (2, 101)
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (3, 102)
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (1, 103)
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (1, 104)
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (2, 105)
INSERT [dbo].[testing_new] ([id], [pid]) VALUES (4, 106)
;with a as
(
SELECT [ID],[PID],
rn = row_number() over (partition by [ID] order by ID)
FROM testing_new
)
select
[ID],[PID] from a
where rn = 1