福永公司网站建设,嘉兴设计公司有哪些,携程企业网站建设的思路,网站建设公司策划【题目要求】 数据库中有一张地区数据统计表#xff0c;但是并不规则 #xff0c;记录类似于#xff0c;225100:02:3:20160725是一串代码#xff0c;以#xff1a;分割#xff0c;第1位为地区代码#xff0c;第2位为分类代码#xff0c;第3位为数量#xff0c;第4位为… 【题目要求】 数据库中有一张地区数据统计表但是并不规则 记录类似于225100:02:3:20160725是一串代码以分割第1位为地区代码第2位为分类代码第3位为数量第4位为日期 地区代码含义225100-上海 225200-江苏 225300-浙江 为可能有某些位不存在缺位时计算规则如下 1、地区缺位时不参与统计 2、时间缺位时按20151220来计算 数据如下 现要求输入开始日期和结束日期后自动统计这个时间段内每个地区和各个分类下的数据情况。日期控件中输入的日期格式要求为yyyy-MM-dd 【数据来源】考试数据库wubmh0及chq3g4表 【效果图参考】 其中使用的是SQLite数据库需要编写分隔符列转行语句
with split(id,splid,idsstr) as
(select id,,part||; from chq3g4 UNION ALL SELECT id,substr(idsstr, 0, instr(idsstr, ;)),substr(idsstr, instr(idsstr, ;)1)FROM split WHERE idsstr!
)
SELECT t1.cityid,t1.city,t2.tp,t2.num,t2.dy
FROM wubmh0 t1
left join (select splid,id,case when substr(splid,-1) : then substr(splid,-8,4)||-||substr(splid,-4,2)||-||substr(splid,-2) else2015-12-20 end as dy,substr(splid,1,6) as city,substr(splid,8,2) as tp,case when substr(splid,11,instr(substr(splid,10),:)): then 0 else substr(splid,11,instr(substr(splid,11),:)-1) end as numfrom splitwhere splid ! ) t2
on t1.cityidt2.city
where dy between ${start} and ${end};
后面排版就很容易了