There is a table in which random integers are written. It is necessary to group the numbers by hundreds and from each hundred select 10 random values.
Here is an example of a request from the table:
SELECT TOP 10 [ID] ,[Phone] FROM [CallList].[dbo].[hundreds] ID Phone ----------- ------ 1 210001 2 210002 3 210003 4 210004 5 210006 6 210007 7 210008 8 210009 9 210010 10 210011 Next, I evolved to:
SELECT *,ROW_NUMBER() OVER (PARTITION BY hundr order by hundr) as 'num' FROM ( SELECT id, phone, cast(phone/100 as int) as 'hundr' FROM [CallList].[dbo].[hundreds]) x How out of what came out to get 10 random numbers from each hundred?