办证系统办证量统计
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and card_state in ('1','2','4','6','7')
group by userinfo.branchcode; ---有效证
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and card_state in ('3','5')
group by userinfo.branchcode; ---退证
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2015/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2017/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
group by userinfo.branchcode;---新办证
select userinfo.voucher_no || ',' as voucher_no ,userinfo.fullname, reader_card.card_no ,reader_card.card_type ,card_time from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time >= to_date('2019/3/21 11:00:00','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time <= to_date('2019/3/21 13:0:0','yyyy-MM-dd hh24:mi:ss') and reader_card.create_user = 'admin' order by reader_card.card_time desc
select to_char(operation_date, 'yyyy-MM-dd') ,count( id ) from reader_card_log
where reader_card_log.operation_date > to_date('2019-01-01 00:02:00', 'yyyy-MM-dd hh24:mi:ss')
and reader_card_log.operation_type = '1'
group by to_char(operation_date, 'yyyy-MM-dd') order by count( id ) desc ; --每天的办证两
select count(user_code) from reader_card where reader_card.create_date < to_date('2017-01-01 00:02:00', 'yyyy-MM-dd hh24:mi:ss'); --截止时间的办证量
select count(user_code) from reader_card where reader_card.create_date > to_date('2019-01-01 00:02:00', 'yyyy-MM-dd hh24:mi:ss'); --大于止时间的办证量
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2019/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2021/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib') and card_type.is_adult != 'Y')
group by userinfo.branchcode;---新办证 (少儿)
--- 4642
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2019/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2021/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib') and card_type.is_adult = 'Y')
group by userinfo.branchcode;---新办证 (成人)
-- 15560
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2019/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2021/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib') and card_type.is_adult = 'Y')
and trim(translate(userinfo.voucher_no,'0123456789',' ')) is NULL
and (to_char(sysdate, 'yyyy') - substr(userinfo.voucher_no, 7, 4)) > 59
group by userinfo.branchcode; ---新办证 (成人 > 59)
-- 93
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2019/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2021/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib') and card_type.is_adult = 'Y')
and trim(translate(userinfo.voucher_no,'0123456789',' ')) is NULL
and (to_char(sysdate, 'yyyy') - substr(userinfo.voucher_no, 7, 4)) >= 14
and (to_char(sysdate, 'yyyy') - substr(userinfo.voucher_no, 7, 4)) <= 59
group by userinfo.branchcode ; ---新办证 (成人 14-59 )
-- 14089
select * from userinfo where trim(translate(userinfo.voucher_no,'0123456789',' ')) is NULL ;
select * from userinfo
select (to_char(sysdate, 'yyyy') - substr(userinfo.voucher_no, 7, 4)) age from userinfo where userinfo .voucher_no = '330182198409302315';
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2020/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2022/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib'))
group by userinfo.branchcode;---新办证 27867
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and reader_card.card_time > to_date('2020/12/31 23:59:59','yyyy-MM-dd hh24:mi:ss')
and reader_card.card_time < to_date('2022/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card.create_user ='aliwindow'
and userinfo.create_user ='aliwindow'
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib'))
group by userinfo.branchcode;---支付宝新办证 -24678
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and card_state in ('3','5')
and reader_card.card_type in (select card_type_code from card_type where card_type.branchcode in ('sxslib'))
group by userinfo.branchcode; ---退证 143694
select userinfo.branchcode ,count(userinfo.user_code) from reader_card , userinfo
where reader_card.user_code = userinfo.user_code and card_state in ('1','2','4','6','7')
group by userinfo.branchcode; ---有效证 272734
//分单位的退证情况
select count(*) from reader_card_log where reader_card_log.operation_type = '8'
and reader_card_log.operation_date > to_date('2021/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card_log.operation_date < to_date('2022/1/1 0:0:0','yyyy-MM-dd hh24:mi:ss')
and reader_card_log.clerk in (
select adm_user.user_code from adm_user where user_id in (
select bas_department_user .user_id from bas_department_user where dept_id = 'ff80808149dcdf530149dce3584e0000'
) )