Hi nedash,
Refer the below sql sample.
ALTER PROCEDURE [dbo].[NewOrder_Information]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Test AS TABLE(PeygiriCode INT,PostType INT,NAME VARCHAR(50),ID INT IDENTITY)
INSERT INTO @Test VALUES(123,1,'neda')
INSERT INTO @Test VALUES(123,1,'neda')
INSERT INTO @Test VALUES(123,1,'neda')
INSERT INTO @Test VALUES(450,2,'sara1')
INSERT INTO @Test VALUES(451,1,'sara2')
INSERT INTO @Test VALUES(452,1,'sara3')
INSERT INTO @Test VALUES(453,1,'sara4')
INSERT INTO @Test VALUES(454,2,'sara5')
INSERT INTO @Test VALUES(455,1,'sara6')
INSERT INTO @Test VALUES(456,1,'sara7')
INSERT INTO @Test VALUES(457,1,'sara8')
INSERT INTO @Test VALUES(458,2,'sara9')
INSERT INTO @Test VALUES(459,1,'sara10')
INSERT INTO @Test VALUES(460,1,'sara11')
INSERT INTO @Test VALUES(461,1,'sara12')
INSERT INTO @Test VALUES(462,2,'sara13')
SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0) ASC)AS RowNumber,PeygiriCode,PostType,NAME,id
INTO #Results
FROM (SELECT ROW_NUMBER() OVER(PARTITION BY PeygiriCode ORDER BY id ASC) RNo,PeygiriCode,PostType,NAME,id FROM @Test)a
WHERE RNo = 1
SELECT @RecordCount = COUNT(*) FROM #Results
SELECT PeygiriCode,PostType,NAME,id FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
EXEC [dbo].[NewOrder_Information] 1,5,5
EXEC [dbo].[NewOrder_Information] 2,5,5
EXEC [dbo].[NewOrder_Information] 3,5,5
Screenshot