Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Número de lote incremental do SQL SELECT a cada X linhas


Isso deve funcionar:
select ROW_NUMBER() OVER (Order by (select 0)) AS RowNumber,
(case when convert(int, (ROW_NUMBER() OVER (Order by (select 0)) % 5))=0 then 0 else 1 end) + convert(int, (ROW_NUMBER() OVER (Order by (select 0)) / 5)) as BatchNumber,
* from WorkQueue