select
         pha.segment1                     报价单号
     -- ,pha.end_date
     -- ,decode(pha.status_lookup_code,'A','有效','C','关闭','I','过程中')    状态

,pv.vendor_name                    供应商
         ,papf.full_name              报价输入人员
         ,msi.segment1                          项目
         ,msi.description                   项目说明
         ,msi.primary_unit_of_measure    单位
         ,pla.line_num                               行
         ,decode(pla.line_type_id,'1','货物','1000','估价')    报价类型
         ,pla.unit_price                           单价
         ,pla.creation_date               新建日期
         ,pla.last_update_date          更新日期
         ,fu.description                        更新人
from  inv.mtl_system_items_b            msi
        ,po.po_headers_all                    pha
        ,po.po_lines_all                          pla
        ,po.po_vendors                           pv
        ,po.po_agents                             pa
        ,HR.PER_ALL_PEOPLE_f            papf
        ,applsys.fnd_user                        fu
where msi.inventory_item_id = pla.item_id
   and pha.po_header_id = pla.po_header_id
   and msi.organization_id = X
   and pha.agent_id = pa.agent_id
   and pha.vendor_id = pv.vendor_id
   and pha.type_lookup_code = 'BLANKET'--'QUOTATION'
   and papf.PERSON_ID = pha.agent_id
   and fu.user_id = pla.created_by
   and pha.end_date > to_date('20**0131','yyyymmdd')
-- and pha.end_date is null
--and pha.status_lookup_code <> 'C'
--and msi.segment1 like '&ITEM'
  order by
           msi.segment1,
           pv.vendor_name

04-30 13:08