交叉应用的替代方法(在 X in() 上加入)
Alternative to cross apply (join on X in())
经过大量工作,我做了这个(正确的)查询:
select count(distinct t1.code+t1.flname+t1.col1+t2.flname)
from #t4 t1 cross apply (select flname from #t4 sq where sq.col1=t1.col1)t2
经过更多的工作,我未能在不使用交叉应用的情况下生成等效查询。可能吗?也许与 WITH?不使用 WITH 怎么样?
一个简单的join
应该等价于:
select count(distinct t1.code + t1.flname + t1.col1 + sq.flname)
from #t4 t1 join
#t4 sq
on sq.col1 = t1.col1;
经过大量工作,我做了这个(正确的)查询:
select count(distinct t1.code+t1.flname+t1.col1+t2.flname)
from #t4 t1 cross apply (select flname from #t4 sq where sq.col1=t1.col1)t2
经过更多的工作,我未能在不使用交叉应用的情况下生成等效查询。可能吗?也许与 WITH?不使用 WITH 怎么样?
一个简单的join
应该等价于:
select count(distinct t1.code + t1.flname + t1.col1 + sq.flname)
from #t4 t1 join
#t4 sq
on sq.col1 = t1.col1;