您的位置:首页 > 数据库

几个sql语句

2016-12-06 17:45 302 查看
select count(distinct(company_name)) from bj_capital       60/69

select count(distinct(company_name)) from bj_capital2       134/193

SELECT company_name FROM bj_capital UNION SELECT company_name FROM bj_capital2      194/262

create table clue.bj_union_capital as
SELECT distinct c.company_name,c.reg_no, c.city, c.bus_scope FROM  clue.clue  c
JOIN
(SELECT company_name FROM bj_capital UNION SELECT company_name FROM bj_capital2)  b
ON c.company_name = b.company_name
where length(bus_scope)>=6 and length(reg_no)>=15

select count(1) from bj_union_capital                      62

select
sum(case when bus_scope like '%钢铁%' or bus_scope like '%汽车%' or bus_scope like '%船舶%' or bus_scope like '%石化%' or bus_scope like '%纺织%' or bus_scope like '%轻工%' or bus_scope like '%有色金属%' or bus_scope like '%装备制造%' then 1 else 0 end)  type_cnt
,sum(case when bus_scope like '%预防性疫苗%' or bus_scope like '%治疗性疫苗%' or bus_scope like '%诊断试剂%' then 1 else 0 end)  type2_cnt
,sum(case when bus_scope like '%新型医用植入器械%' or  bus_scope like '%人工器官%' or bus_scope like '%医学影像诊断设备%' or bus_scope like '%微创诊疗设备%' or bus_scope like '%新型肿瘤治疗装置%%' then 1 else 0 end)  type3_cnt
,sum(case when bus_scope like '%秸秆成型燃料%' or bus_scope like '%秸秆气化%' or bus_scope like '%秸秆干馏%' or bus_scope like '%秸秆能源化%' then 1 else 0 end)  type4_cnt
,sum(case when bus_scope like '%信息技术%' or bus_scope like '%生物和医药技术%' or bus_scope like '%新材料技术%' or bus_scope like '%先进制造技术%' or bus_scope like '%资源环境技术%' or bus_scope like '%海洋技术%' or bus_scope like '%现代农业技术%' or bus_scope like '%现代交通技术%' or bus_scope like '%地球观测与导航技术%' then 1 else 0 end)  type5_cnt
,sum(case when ic_cap>10000000 then 1 else 0 end)  type6_cnt
,sum(case when ic_cap>30000000 then 1 else 0 end)  type7_cnt
from clue a

select
sum(case when bus_scope regexp '担保' then 1 else 0 end)  type_cnt
,sum(case when bus_scope regexp '技术进出口' then 1 else 0 end)  type2_cnt
,sum(case when bus_scope regexp '货物进出口' then 1 else 0 end)  type3_cnt
,sum(case when bus_scope regexp '融资' then 1 else 0 end)  type4_cnt
,sum(case when bus_scope regexp '文化艺术' then 1 else 0 end)  type5_cnt
,sum(case when bus_scope regexp '演出' then 1 else 0 end)  type6_cnt
,sum(case when bus_scope regexp '生物试剂' then 1 else 0 end) type7_cnt
,sum(case when bus_scope regexp '生物技术' then 1 else 0 end) type8_cnt

from clue a

bus_scope regexp '钢铁|汽车|船舶|石化|纺织|轻工|有色金属|装备制造'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql