select sbbh ,'122767' as sjd,
(select count(*) lx0 from cltx b where b.sbbh=a.sbbh and b.cllx=0 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx0,
(select count(*) lx1 from cltx b where b.sbbh=a.sbbh and b.cllx=1 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx1,
(select count(*) lx2 from cltx b where b.sbbh=a.sbbh and b.cllx=2 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx2,
(select count(*) lx3 from cltx b where b.sbbh=a.sbbh and b.cllx=3 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx3
from (select distinct sbbh from cltx where sbbh in(
'51002312900071','51002312900072','51002312900031','51002312900032','51002312800071','51002312800072','51002312800031','51002312800032','51002313200011',
'51002313200012','51001101700071','51001101700072','51001101700031','51001101700032','51001101800071','51001101800072','51001101800031','51001101800032',
'51001101800081','51009100300011','51009100300012','51009100300051','51009100300052','51009100400011','51009100400012','51009100400051','51009100400052',
'51009100500011','51009100500012','51009100500051','51009100500052','51004102000011','51004102000012','51004102000051','51004102000052','51005100200011',
(select count(*) lx0 from cltx b where b.sbbh=a.sbbh and b.cllx=0 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx0,
(select count(*) lx1 from cltx b where b.sbbh=a.sbbh and b.cllx=1 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx1,
(select count(*) lx2 from cltx b where b.sbbh=a.sbbh and b.cllx=2 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx2,
(select count(*) lx3 from cltx b where b.sbbh=a.sbbh and b.cllx=3 and b.jgsj >=to_timestamp('2013-12-27 06:00:00.000','yyyy-mm-dd hh24:mi:ss.xff') and b.jgsj < to_timestamp('2013-12-27 07:00:00.000','yyyy-mm-dd hh24:mi:ss.xff')) lx3
from (select distinct sbbh from cltx where sbbh in(
'51002312900071','51002312900072','51002312900031','51002312900032','51002312800071','51002312800072','51002312800031','51002312800032','51002313200011',
'51002313200012','51001101700071','51001101700072','51001101700031','51001101700032','51001101800071','51001101800072','51001101800031','51001101800032',
'51001101800081','51009100300011','51009100300012','51009100300051','51009100300052','51009100400011','51009100400012','51009100400051','51009100400052',
'51009100500011','51009100500012','51009100500051','51009100500052','51004102000011','51004102000012','51004102000051','51004102000052','51005100200011',
'51005100200012','51005100200051','51005100200052','51002312900071','51002312900072','51002312900031','51002312900032','51001101800041')) a