with 建立臨時表

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

posted @ 2011-06-10 11:18  左安  阅读(253)  评论(0编辑  收藏  举报