临海小憇

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3959|回复: 0
打印 上一主题 下一主题

[需求] 不可收费耗材绩效考核数据-科室反馈表格

[复制链接]

100

主题

121

帖子

8552

积分

论坛元老

Rank: 8Rank: 8

积分
8552
跳转到指定楼层
楼主
发表于 2017-6-9 16:39:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

执行的sql如下:


select '2017上',

       '*',

       F_GET_COM_DICT_NAME(m.source_code, 'sourceCode'),

       m.office_id,

       (select org.org_name

          from tb_usc_org org

         where org.org_id = m.office_id),

       (select org.org_name

          from tb_usc_org org

         where org.org_id = (select decode(org1.parent_org_id,

                                           '00001000',

                                           org1.org_id,

                                           org1.parent_org_id)

                               from tb_usc_org org1

                              where org1.org_id = m.office_id)),

       '',

       m.wh_to_id XH,

       (select wh_name from tb_usc_warehouse where wh_id = m.wh_bill_id),

       m.import_master_id,

       m.material_id,

       m.material_name,

       m.material_spec,

       F_GET_COM_DICT_NAME((select material.charge_type

                             from tb_usc_material material

                            where material.material_id = m.material_id),

                           'chargeType'),

       m.unite_price,

       m.import_quantity,

       m.total,

       m.MC

  from (

        

        select apply.source_code,

                apply.project_number,

                dtl.import_master_id,

                (select wu.office_id

                   from tb_usc_warehouse wu

                  where wu.wh_id = import.wh_to_id) office_id,

                import.wh_to_id,

                import.wh_bill_id,

                dtl.material_id,

                dtl.material_name,

                dtl.material_spec,

                sum(dtl.import_quantity) import_quantity,

                dtl.unite_price,

                sum(dtl.import_quantity * dtl.unite_price) total,

                '专购出库' MC

          from tb_usc_po_master      po,

                tb_usc_po_plan_master plan,

                tb_usc_apply_master   apply,

                tb_usc_import_master  import,

                tb_usc_import_detail  dtl

         where po.source_doc_no = plan.po_plan_master_id

           and plan.source_doc_no = apply.apply_master_id

           and import.po_master_id = po.po_master_id

           and dtl.import_master_id = import.import_master_id

           and import.status = '05'

           and dtl.update_date between to_date('2017-05-31', 'yyyy-mm-dd') and

               to_date('2017-06-01', 'yyyy-mm-dd')

         group by apply.source_code,

                   apply.project_number,

                   dtl.import_master_id,

                   import.wh_to_id,

                   import.wh_bill_id,

                   dtl.material_id,

                   dtl.material_name,

                   dtl.material_spec,

                   dtl.unite_price

        union all

        select apply.source_code,

                apply.project_number,

                dtl.stock_transfer_id,

                (select wu.office_id

                   from tb_usc_warehouse wu

                  where wu.wh_id = dtl.wh_to_id) office_id,

                dtl.wh_to_id,

                dtl.wh_from_id,

                dtl.material_id,

                dtl.material_name,

                dtl.material_spec,

                sum(dtl.process_quantity),

                dtl.unite_price,

                sum(dtl.process_quantity * dtl.unite_price),

                '库发出库' MC

          from tb_usc_stock_transfer_master transfer,

                tb_usc_apply_master          apply,

                tb_usc_stock_transfer_detail dtl

         where transfer.apply_master_id = apply.apply_master_id

           and dtl.stock_transfer_id = transfer.stock_transfer_id

           and (transfer.status = '04' or

               (transfer.status = '05' and dtl.status = 'Y'))

           and dtl.update_date between to_date('2017-05-31', 'yyyy-mm-dd') and

               to_date('2017-06-01', 'yyyy-mm-dd')

         group by apply.source_code,

                   apply.project_number,

                   dtl.stock_transfer_id,

                   dtl.wh_to_id,

                   dtl.wh_from_id,

                   dtl.material_id,

                   dtl.material_name,

                   dtl.material_spec,

                   dtl.unite_price) m

                   

                   order by  6

                   

                   


           



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|临海小憇 ( 鲁ICP备16010828号-2

GMT+8, 2024-4-25 23:49 , Processed in 0.044033 second(s), 7 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表