有一个表已经建立了一个标识列,不过现在在查询中存在条件select * from table a where ...,当然标识列也就不连续.现在想获得的是一个顺序增长连续的如何处理,结果如下
a b 1
d d 2
4 s 3
s 4 4
使用newid()不能获得整数,使用select identity(int,1,1)结果在查询中不能使用,不知道有啥办法?
a b 1
d d 2
4 s 3
s 4 4
使用newid()不能获得整数,使用select identity(int,1,1)结果在查询中不能使用,不知道有啥办法?
(select count(*) from tablename where 条件 and 标识列<=a.标识列) as 序号
from tablename a
where 条件
order by 标识列
select (select count(*) from authors where au_id <a.au_id),* from authors a order by au_id