云星空常用查询脚本

1. 存货成本及金额

select kf.fnumber,cha.fyear,cha.FPERIOD,wla.fnumber,wl.fname,ch.* from V_HS_BALANCE ch  left join V_HS_OUTACCTG cha on  cha.fid=ch.fid left join  T_BD_Material_L wl   on ch.FMASTERID=wl.FMATERIALID left join  T_BD_Material wla   on ch.FMASTERID=wla.FMATERIALID left join t_BD_Stock kf on kf.FMASTERID=ch.FSTOCKID where cha.fyear=2023 and  cha.FPERIOD=1

2. 产量数据

select case when dep.fnumber in ('20.0026') then '中药提取车间' when dep.fnumber in ('20.0062','20.0063','20.0064','20.0065','20.0066','20.0067','20.0068','20.0069','20.0076','20.0031','20.0056') then '输液车间'   when dep.fnumber in ('20.0070','20.0083','20.0030') then '口服液车间'  else '公共车间' end   cjname, case when dep.fnumber in ('20.0062','20.0069') then '玻瓶生产线' when dep.fnumber in ('20.0066','20.0068') then '塑瓶生产线'  when dep.fnumber in ('20.0067') then '塑瓶直立袋软袋生产线' when dep.fnumber in ('20.0070') then '口服液线'  else '无' end   cxname, dep.fnumber,dept.fname,wla.fnumber,wl.fname,wl.FSPECIFICATION  from T_PRD_INSTOCKENTRY a  left join T_PRD_INSTOCK b on a.fid =b.fid  left join T_BD_DEPARTMENT_L dept on dept.FDEPTID=a.FWorkShopId   left join T_BD_DEPARTMENT dep on dep.FDEPTID=a.FWorkShopId   left join  T_BD_Material_L wl   on a.FMaterialId=wl.FMATERIALID   left join  T_BD_Material wla   on a.FMaterialId=wla.FMATERIALID  

3. 从凭证取科目借方发生额

select dept.fname,acct.FNAME,a.FDEBIT,a.FDC  from T_GL_VOUCHERENTRY a left join T_BD_FLEXITEMPROPERTY b  on a.FDetailID=b.fid left join T_BD_FLEXITEMDETAILV c on c.fid=a.FDETAILID  left join T_BD_DEPARTMENT_L dept on dept.FDEPTID=c.FFLEX5   left join   T_BD_ACCOUNT_L acct on acct.FACCTID=a.FACCOUNTID