Are you looking for something like this?use northwindgocreate table #temp(Employee varchar(15),Supervisor tinyint null,rowcnt [int] IDENTITY (1, 1) NOT NULL ,)insert into #tempselect top 10 Lastname, null from employees where reportsto is not null order by lastnameinsert into #temp select top 5 LastName, 1 from employees where reportsto is null order by lastnameselect 'emgroup' + cast(rowcnt as varchar(3)), Employee, case Supervisor when 1 then 'Supervisor' Else 'Employee' endfrom #tempdrop table #temp
An infinite universe is the ultimate cartesian product.