日期:2014-05-17 浏览次数:20442 次
select a.piaolei,a.renshu,b.mingcheng as pl from Tbl_checkIn a,tbl_PiaoLei b where a.piaolei=b.bianhao and convert(char(10),CheckInTime,120) >= '2012-08-16' and convert(char(10),CheckInTime,120) <= '2012-08-16' and CheckInNo='01' and left(e.mingcheng,3)='北京市'
select sum(a.renshu) as renshu from Tbl_checkIn a,tbl_PiaoLei b where a.piaolei=b.bianhao and convert(char(10),CheckInTime,120) >= '2012-08-16' and convert(char(10),CheckInTime,120) <= '2012-08-16' and CheckInNo='01' and left(e.mingcheng,3)='北京市'
------解决方案--------------------
select renshu,count(1) from (select a.piaolei,a.renshu,b.mingcheng as pl from Tbl_checkIn a,tbl_PiaoLei b where a.piaolei=b.bianhao and convert(char(10),CheckInTime,120) >= '2012-08-16' and convert(char(10),CheckInTime,120) <= '2012-08-16' and CheckInNo='01' and left(e.mingcheng,3)='北京市' )t group by 人数