獲得省市區的統計資訊

2021-08-02 08:32:41 字數 1134 閱讀 7246

問題描述:

獲取各個省市的統計資訊

,如 浙江省,則需要獲取省市區的所有統計資訊,如浙江省+浙江省下所有的市+浙江省下所有的市下的所有區

杭州市,則需要獲取杭州市+杭州市下所有區的統計資訊

濱江區,則獲取濱江區的統計資訊,

思路:獲取所有的省市區的資訊 + 省的統計資料+市的統計資料,做關聯查詢,因為設定省市區的為模式為下劃線_  如  浙江省_寧波市_北侖區

所有判斷下劃線的個數來讀取哪個統計數量

例項**如下

浙江省_寧波市_北侖區

select c2.city ,

case char_length(c2.city)-char_length(replace(c2.city,'_',''))

when 0 then c1.amount

when 1 then c3.amount

when 2 then c2.amount else ''   end amount

from

(select count(0) amount, '浙江省' city

from fm_sample s

where s.data_status=0

) c1

right join

(select

(select u.precinct_name from sys_unit u where u.id=s.sample_audit_unit_id) city,

count(0) amount

from fm_sample s

where s.data_status=0

group by city

) c2 on c1.city=c2.city

left join

(select

(select back_province_city_func(u.precinct_name) from sys_unit u where u.id=s.sample_audit_unit_id) city,

count(0) amount

from fm_sample s

where s.data_status=0

group by city

) c3 on c2.city=c3.city

全國省市區資料SQL 省市區

drop table if exists provinces create table provinces id int 11 not null auto increment,provinceid varchar 20 not null,province varchar 50 not null,pr...

省市區陣列

先找到檔案對應的路徑 nsstring path users dlios desktop oc5 省市區陣列 oc5 省市區陣列 area.txt 通過路徑產生字串,內容就是txt文字裡的內容 nsstring str nsstring stringwithcontentsoffile path e...

OC 省市區陣列

省市區陣列 先找到檔案對應的路徑 nsstring path users dlios desktop 筆記 oc筆記 oc5 陣列省市區 oc5 陣列省市區 area.txt 通過路徑產生字串,內容就是txt文字的內容 nsstring str nsstring stringwithcontents...