+ -
当前位置:首页 → 问答吧 → 链接两个table

链接两个table

时间:2011-11-29

来源:互联网

SQL code
select 
a.shiftid,a.[count],
sum(case when b.system like 'cimpack%' then job else 0 end) as cimpack,
sum(case when b.system like 'floortrack%' then job else 0 end) as floortrack
from t1 inner joint t2 on t1.shiftid=b.shiftid
group by a.shiftid,a.[count]

作者: roy_88   发布时间: 2011-11-29

改改
SQL code
select 
a.shiftid,a.[count],
sum(case when b.system like 'cimpack%' then job else 0 end) as cimpack,
sum(case when b.system like 'floortrack%' then job else 0 end) as floortrack
from t1 as a inner joint t2 as b on t1.shiftid=b.shiftid
group by a.shiftid,a.[count]

作者: roy_88   发布时间: 2011-11-29

SQL code
select 
  a.shiftid,a.[count],
  sum(case when b.system like 'cimpack%' then job else 0 end) as cimpack,
  sum(case when b.system like 'floortrack%' then job else 0 end) as floortrack
from
 a ,b 
where
 a.shiftid=b.shiftid
group by
 a.shiftid,a.[count]

作者: fredrickhu   发布时间: 2011-11-29

热门下载

更多