查询照料中心2018签到数【街道、照料中心、中心等级、1月、2月、3月、4月、5月、6月、7月、8月、9月、10月、11月、12月、1-12月合计签到、累计签到】

SELECT jie.name as "所属街道",cen.name as "照料中心",cen.grade as "中心等级",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-1-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-1-31' )  as "1月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-2-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-2-28' )  as "2月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-3-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-3-31' )  as "3月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-4-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-4-30' )  as "4月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-5-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-5-31' )  as "5月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-6-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-6-30' )  as "6月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-7-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-7-31' )  as "7月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-8-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-8-31' )  as "8月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-9-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-9-30' )  as "9月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-10-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-10-31' )  as "10月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-11-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-11-30' )  as "11月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-12-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-12-31' )  as "12月签到数",
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-1-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-1-31' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-2-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-2-28' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-3-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-3-31' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-4-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-4-30' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-5-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-5-31' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-6-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-6-30' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-7-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-7-31' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-8-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-8-31' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-9-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-9-30' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-10-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-10-31' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-11-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-11-30' ) +
   (select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) >='2018-12-1'  and cast(to_char(card."ACTIVETIME",'YYYY-MM-DD') as date) <='2018-12-31' ) as "1-12月合计签到数",
(select count(*) from member_cardrecord card where cen.id=card.yanglaocenter_ref) as "累计签到数"
FROM yanglao_org_jiedao jie JOIN yanglao_org_yanglaocenter cen ON jie.id=cen.jiedao_ref
WHERE cen.name='水洞埭社区居家养老服务照料中心'or
   cen.name='永丰社区居家养老服务照料中心'or
   cen.name='如意社区居家养老照料中心'or
   cen.name='百花社区居家养老服务照料中心【朝阳路点】'or
   cen.name='南市社区居家养老服务照料中心'or
   cen.name='三北村居家养老服务照料中心'or
   cen.name='塘桥村居家养老服务照料中心'or
   cen.name='大胜村居家养老服务照料中心'or
   cen.name='三港新城社区居家养老服务照料中心'or
   cen.name='东升社区居家养老服务照料中心'or
   cen.name='钱家村居家养老服务照料中心'or
   cen.name='虹霓村居家养老服务照料中心'or
   cen.name='洁芳社区居家养老服务照料中心'or
   cen.name='沐阳社区居家养老服务照料中心'or
   cen.name='松枫社区居家养老服务照料中心'or
   cen.name='北河溇社区居家养老服务照料中心'or
   cen.name='梅兰苑社区居家养老服务照料中心'or
   cen.name='黄家浜村居家养老服务照料中心'or
   /*未接入*/cen.name='南河头社区居家养老服务照料中心'or
   cen.name='滨湖社区居家养老服务照料中心'or
   cen.name='梅园社区居家养老服务照料中心'or
   cen.name='凤凰社区居家养老服务照料中心'or
   cen.name='永兴社区居家养老服务照料中心陆家桥点'or
   cen.name='新群社区居家养老服务照料中心'or
   cen.name='花园社区居家养老服务照料中心'or
   cen.name='钟埭村居家养老服务照料中心'or
   cen.name='钟南村居家养老服务照料中心'or
   cen.name='永兴社区居家养老服务照料中心宏建点'or
   cen.name='三友社区居家养老服务照料中心'or
   cen.name='白马堰社区居家养老服务照料中心'or
   cen.name='沈家弄居家养老服务照料中心'or
   cen.name='大力村居家养老服务照料中心'or
   cen.name='西林寺社区居家养老服务照料中心'or
   /*未接入*/cen.name='福臻社区居家养老服务照料中心'or
   cen.name='钟埭社区居家养老服务照料中心'or
   cen.name='全公亭社区居家养老服务照料中心'or
   cen.name='聚福村居家养老服务照料中心'or
   cen.name='渡船桥村居家养老服务照料中心'or
   cen.name='赵家桥村居家养老服务照料中心'or
   cen.name='独山港社区居家养老服务照料中心'or
   cen.name='龙吟社区居家养老服务照料中心'or
   cen.name='虎啸社区居家养老服务照料中心'or
   cen.name='林埭社区居家养老服务照料中心'or
   cen.name='群丰村居家养老服务照料中心'or
   cen.name='龙萌村居家养老服务照料中心'or
   cen.name='曹港村居家养老服务照料中心'or
   cen.name='中华村居家养老服务照料中心'or
   cen.name='双红村居家养老服务照料中心'or
   cen.name='友联村居家养老服务照料中心'or
   cen.name='新仓社区居家养老服务照料中心'or
   cen.name='三叉河村居家养老服务照料中心'or
   cen.name='芦湾村居家养老服务照料中心'or
   cen.name='杉青港村居家养老服务照料中心'or
   cen.name='石路村居家养老服务照料中心'or
   cen.name='曹桥社区居家养老服务照料中心'or
   cen.name='石龙村居家养老服务照料中心'or
   cen.name='百寿村居家养老服务照料中心'or
   cen.name='愚桥村居家养老服务照料中心'or
   cen.name='孔家堰村居家养老服务照料中心'or
   cen.name='野马村居家养老服务照料中心'or
   /*未接入*/cen.name='严家门村居家养老服务照料中心'or
   cen.name='勤安村居家养老服务照料中心'or
   cen.name='马厩村居家养老服务照料中心'or
   cen.name='星光村居家养老服务照料中心'or
   cen.name='新埭社区居家养老服务照料中心'or
   cen.name='鱼圻塘村居家养老服务照料中心'or
   cen.name='姚浜村居家养老服务照料中心'
ORDER BY jie.name

你可能感兴趣的:(查询照料中心2018签到数【街道、照料中心、中心等级、1月、2月、3月、4月、5月、6月、7月、8月、9月、10月、11月、12月、1-12月合计签到、累计签到】)