You can use Row_Number() Over Partition to to group the Data into a virtual table and then select from the virtual table and Order the result-set according to your ordering criteria as follows:--Creating TableCREATE TABLE [dbo].[Product]([ID] [int] IDENTITY(1,1) NOT NULL, [ProductCode] [int],[NumPersonLikeProduct] [int],[UserPhone] [nvarchar](20),[CreatedOn] [datetime] )--Inserting Sample DataInsert into ProductSelect 254, 338, '1123231355', '2012/02/09'Union ALL Select 184, 71, '9988672521', '2012/03/04' Union ALL Select 833, 286, '9897527628', '2012/04/05'--Query For Your RequirementSelect ProductCode, UserPhone From(Select *, ROW_NUMBER() Over (Partition By ProductCode Order By UserPhone) As rn From Product) As aOrder By NumPersonLikeProduct, CreatedOn
N 28° 33' 11.93148"E 77° 14' 33.66384"