select identity(int,1,1) as id ,* into #t1 from a select identity(int,1,1) as id ,* into #t2 from b select code, name, class, point from #t1 a left join #t2 b on a.id=b.id
不会吧,表B没有code这个字段??那靠什么关联呀? 假设有这个字段 SELECT A.*,B.* from A LEFT OUTER JOIN B ON A.code=B.code
select id=identity(int),* into #t from 表B select a.*,b.class,b.point from 表A a left join #t b on b.id=(select count(*) from 表A where code<=a.code) drop table #t
select * from 表A a left join 表B b on (select count(*) from 表A where code<=a.code) =(select count(*) from 表B where class<=b.class)
就是这个要求。请帮忙。
select identity(int,1,1) as id ,* into #t2 from b
select code, name, class, point from #t1 a left join #t2 b on a.id=b.id
假设有这个字段
SELECT A.*,B.* from A LEFT OUTER JOIN B ON A.code=B.code
select a.*,b.class,b.point
from 表A a
left join #t b on b.id=(select count(*) from 表A where code<=a.code)
drop table #t
from 表A a
left join 表B b
on (select count(*) from 表A where code<=a.code)
=(select count(*) from 表B where class<=b.class)