if object_id('t1') is not null
drop table t1
go
create table t1(col1 varchar(100),col2 varchar(20),col3 varchar(30))
insert into t1
select 'a','100','' union all
select 'f','100','' union all
select 'g','100','' union all
select 'b','100','' union all
select 'c','200','' union all
select 'd','200','' union all
select 'e','300','' union all
select 'h','100','' union all
select 'i','100','' union all
select 'j','100',''
FN1:
select col1,col2,(select count(*) from t1 as n where n.col1<=w.col1) as col3
from t1 as w
--------------------------------------------
FN2:
select col1,col2,row_number() over(order by col1) as col3 from t1