Q&A for Drupal developers and administrators
declare @view_1 table (ClothingID int, Shoes varchar(10), Shirts varchar(10)) insert into @view_1 select 1, 'v1aaaa3', 'v1aaa2' union select 3, 'v1aabb3', 'v1aaf1' union select 7, 'v1aacc3', 'v1aaf9' union select 10, 'v1aadd5', 'v1aaf7' select *, (select count(*) from @view_1 t1 where t1.ClothingID <= t.ClothingID ) as row from @view_1 t