select count(*) from table where id > (select id from table where name = 'C')
select ROW_NUMBER()Over(ORDER BY id) from table where name='C'
select count(*) from table where id <= 123
declare @t table( [id] int, [name] varchar(20) )insert into @t select 1,'A' union all select 2,'B' union all select 8,'C' union all select 9,'D' union all select 10,'E'select * from @t SELECT *, ROW_NUMBER() OVER ( ORDER BY [name]) AS rowIndex FROM @t
select count(*)
from table
where id > (select id from table where name = 'C')
from table
where id <= 123
declare @t table(
[id] int,
[name] varchar(20)
)insert into @t select 1,'A'
union all select 2,'B'
union all select 8,'C'
union all select 9,'D'
union all select 10,'E'select * from @t SELECT *, ROW_NUMBER()
OVER ( ORDER BY [name]) AS rowIndex
FROM @t