select count(*) from tablename --最大标识列的排列序号select max(标识列) from tablename --最大标识列
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表 order by 姓名select * from #temp where ID_Num between 10 and 20
更正 select identity(int,1,1) as xh ,标识列,姓名 into #temptable from tablename order by 姓名 select #temptable.xh,#temptable.标识列,#temptable.姓名 from #temptable where #temptable.标识列 in (select max(标识列) from tablename)drop table #temptable
select identity(int,1,1)xh,cast(标识列 as int)标识列,Name,.... into #temp from 表 order by Nameselect max(xh) from 表 where Name='姓名'
to 大力: 但现在如果表中已有标识列,是不能通过 select identity(int,1,1) as xh ,标识列,姓名 into #temptable from tablename order by 姓名 加入第二个标识列的。
select count(*) from yourtable A where 姓名 <= (select 姓名 from yourtable where id = (select max(id) from yourtable)
select count(*) from yourtable A where 姓名 <= (select 姓名 from yourtable where id = (select max(id) from yourtable))
select *,identity(int,1,1) as id1 into #tmp from yourtable order by name select id1 from #tmp where id =(select max(id) from #tmp )
select sum(1) from tablename --最大标识列的排列序号
tj_dns提供了最好的解决方法。只有crazyfor提供的代码可以产生第二个标识列。
学习中。 我感觉 select count(*) from yourtable A where 姓名 <= (select 姓名 from yourtable where id = (select max(id) from yourtable)) 是正确的。
select count(*) from tablename --最大标识列的排列序号select max(标识列) from tablename --最大标识列
select identity(int,1,1) as xh ,标识列,姓名 into #temptable
from tablename order by 姓名 select #temptable.xh,#temptable.标识列,#temptable.姓名
from #temptable where #temptable.标识列 in
(select max(标识列) from tablename)drop table #temptable
但现在如果表中已有标识列,是不能通过
select identity(int,1,1) as xh ,标识列,姓名 into #temptable
from tablename order by 姓名
加入第二个标识列的。
where 姓名 <= (select 姓名 from yourtable
where id = (select max(id) from yourtable)
where 姓名 <= (select 姓名 from yourtable
where id = (select max(id) from yourtable))
我感觉
select count(*) from yourtable A
where 姓名 <= (select 姓名 from yourtable
where id = (select max(id) from yourtable))
是正确的。