日期:2014-05-17 浏览次数:20571 次
select sum(case when b.mingcheng='北京' then a.renshu else 0 end) '北京人数',sum(case when b.mingcheng='上海' then a.renshu else 0 end) '上海人数' from Tbl_checkIn a,tbl_PiaoLei b where a.piaolei=b.bianhao and CheckInTime>= '2012-10-01' and CheckInTime<= '2012-10-07' and CheckInNo='01'
select CheckInTime,sum(case when b.mingcheng='北京' then a.renshu else 0 end) '北京人数',sum(case when b.mingcheng='上海' then a.renshu else 0 end) '上海人数' from Tbl_checkIn a,tbl_PiaoLei b where a.piaolei=b.bianhao and CheckInTime>= '2012-10-01' and CheckInTime<= '2012-10-07' and CheckInNo='01' GROUP BY CheckInTime