sql身份证号查人数

select a.*,b.item_name from (select sum(buy_num) num,nqh from (select substr(a.embed_dis_province,1,10) dtime,b.buy_num,case substr(a.idcardcode,1,2) when '11' then '1100' when '12' then '1200' when '31' then '3100' when '50' then '5000' else substr(a.idcardcode,1,4) end as nqh  from f_dd_distri_order a,f_dd_order_products b  where 1=1 and a.order_id=b.order_id and a.dis_order_state='100' AND a.CREATE_DATE >='2016-10-01 00:00:00' AND a.CREATE_DATE <='2016-11-23 23:59:59' ) a group by nqh) a,(select item_name,substr(a.item_code,1,4) code from xt_dictionary_item a where type_id=25 and length(format_code)<=20 and not exists(select 1 from xt_dictionary_item b where type_id=(SELECT xt.TYPE_ID FROM xt_dictionary_type xt WHERE xt.DIC_CODE='GB/T_2260_2013') and substr(b.item_code,1,3) in('110','120','310','500') and length(b.format_code)=20 and a.item_id=b.item_id )) b where a.nqh=b.code order by num desc

 

转载于:https://www.cnblogs.com/niuxi/p/6094417.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值