用查句流水字段,如何做
效果如下:
f1 f2 f3
a b 0001
c d 0002
e f 0003
a g 0004
要求:能用select句。
[解决办法]
select rigth( '000 ' + ltrim(cast(max(f3) as int) + 1), 4) from table
[解决办法]
echiynn() ( ) 信誉:100 Blog 加为好友 2007-07-12 09:52:12 得分: 0
select rigth( '000 ' + ltrim(cast(max(f3) as int) + 1), 4) from table
----------
你只能到0009,再後面的就不行了
[解决办法]
select f1,f2,(select right(10000+count(1),4) from tb where f2 <=a.f2) f3 from tb a order by f3
[解决办法]
select cast(id as int) from t1