第一天上班,好苦逼,老大就丢了个sql给我自己看:
select nvl(sendunit,'合计') 苗源,
case when sendunit is not null and orgname is not null and fadopt is null then '月份合计'
when sendunit is null and fadopt is null then '月份合计'
else to_char(fadopt) end 月份,
orgname crossfield,
-- sum(FADOPTqty) 进苗数,
--sum(qcqty) 残次,
-- sum(deadqty+ttqty) 本期死淘,
decode( sum(FADOPTqty),0,'', decode(round(( sum(deadqty+ttqty))/sum(FADOPTqty) ,3)*100,0,'', to_char( round(( sum(deadqty+ttqty))/sum(FADOPTqty) ,3)*100,'fm9990.00' ) ||'%') ) 本期死淘率,
decode( sum(FADOPTqty),0,'', decode(round(sum(qcqty)/ sum(FADOPTqty) ,3)*100 ,0,'', to_char( round(sum(qcqty)/ sum(FADOPTqty) ,3)*100,'fm9990.00' ) ||'%') ) 残次率,
-- sum(sumdeadqty+sumttqty) 累计死淘 ,
decode( sum(FADOPTqty),0,'', decode(round(( sum(sumdeadqty+sumttqty))/sum(FADOPTqty) ,3)*100,0,'', to_char( round(( sum(sumdeadqty+sumttqty))/sum(FADOPTqty) ,3)*100,'fm9990.00' ) ||'%') ) 累计死淘率
from (
select
/*+ parallel(flk,8) parallel(t_kd_recrearer,8)*/
ws_GetChickAdoptionSendUnit(flk.fid) as sendunit,
to_char(flk.FADOPTDATE,'yyyy-mm') as FADOPT,
cu.fname_l2||'--'||t_org_storage.fname_l2 orgname,
flk.FADOPTqty,
ws_Getrearerche_qcs_l3(flk.fid ,to_date(@dateRange.TDate,'yyyy-mm-dd'),to_date(@dateRange.FDate,'yyyy-mm-dd')) qcqty ,
nvl(ws_Getrearerche_item(flk.fid ,to_date(@dateRange.TDate,'yyyy-mm-dd'),to_date(@dateRange.FDate,'yyyy-mm-dd'),'N/UDQgEeEADgBlx4CgsFAdIIh94='),0) deadqty,
nvl(ws_Getrearerche_item(flk.fid ,to_date(@dateRange.TDate,'yyyy-mm-dd'),to_date(@dateRange.FDate,'yyyy-mm-dd'),'N/UDQgEeEADgBl8VCgsFAdIIh94='),0) ttqty,
nvl(ws_Getrearerche_item(flk.fid ,to_date(@dateRange.TDate,'yyyy-mm-dd'),null,'N/UDQgEeEADgBlx4CgsFAdIIh94='),0) sumdeadqty,
nvl(ws_Getrearerche_item(flk.fid ,to_date(@dateRange.TDate,'yyyy-mm-dd'),null,'N/UDQgEeEADgBl8VCgsFAdIIh94='),0) sumttqty
from t_kd_recbrlrflk flk
inner join t_org_storage on t_org_storage.fid=flk.forgunitwensid
inner join t_bd_material mate on mate.fid=flk.FGENETICSID
inner join t_org_storage cu on t_org_storage.FPARENTID=cu.fid
where 1=1
@flkstatus
@OrgUnit
@adoptrange
) table1
having orgname is not null
group by rollup (sendunit,orgname, FADOPT)
--group by orgname, sendunit,FADOPT
order by sendunit,orgname, FADOPT
--order by decode( 苗源 ,'合计',' Z' , orgname)
--order by decode( 苗源 ,'合计',' Z' , orgname),sendunit,decode( 月份,'月份合计',sysdate , to_date(fadopt,'yyyy-mm') )
一. 自学知识点:
1.oracle函数,decode,rollup等.
rollup函数 http://blog.itpub.net/519536/viewspace-610995/
nvl函数 https://blog.csdn.net/u013538390/article/details/80452377
2.sql server工具的使用;
3.存储过程和函数的深度探究;
4.sql的练习, 用什么工具呢?–fineReport
二.fineReport使用教程
入门视频http://bbs.fanruan.com/lesson-63.html
课程笔记
1.分组报表(其实默认就是分组形式)
备注:销量采取的是求和;
2.自由报表(订单列表)
自由报表的核心:以订单ID为其他单元格的“自定义的左父格坐标”,意思就是每条记录都以此订单id为准。不需要设置横纵。
效果图如下:
3.交叉报表(横表头和纵表头)
交叉报表的核心在于:单元格的相对位置(上下左右)以及设置单元格自身的伸展方向(纵横)!
备注:销量处最好改为”求和”;
4.多源报表(重点– –表关联)
(1)设置需要关联的字段的”左父格”坐标;
(2)单元格元素-过滤,选择外键字段名 = “左父格”坐标.
备注:意思是ds7表(第二张表)的销售员与b8单元格的进行=操作.