with 建立臨時表
with t1 as (select * from employee),
t3 as( select top 1 t2.*
from contract t2 ,t1
where t2.staffid=t1.staffid
)
select t1.staffid,t3.refno
from t1,t3
where t1.staffid=t3.staffid
with 建立臨時表
with t1 as (select * from employee),
t3 as( select top 1 t2.*
from contract t2 ,t1
where t2.staffid=t1.staffid
)
select t1.staffid,t3.refno
from t1,t3
where t1.staffid=t3.staffid
转载于:https://www.cnblogs.com/skyNailZA/archive/2011/06/10/2077438.html