写一SQL,取出某库存组织(p_organization_id)、某时间范围内(p_date_from,p_date_to)、某种事务处理类型(p_transaction_type_id)下发生业务数据,查询数据包括物料编码,物料名称,库存组织ID,库存组织名称,事务处理时间,事务处理类型名称。
HR_ALL_ORGANIZATION_UNITS表
储存ERP的业务实体和库存组织
主要字段:
organization_id  组织ID
bussiness_group_id 业务组ID
location_id 组织地点ID
name 组织名称
date_from 生效日期从          
date_to 生效日期止MTL_SYSTEM_ITEMS_B表主要字段:
inventory_item_id          项目ID
segment1                        物料编码
organization_id              库存组织ID
description                     物料描述
primary_uom_code       主单位
Item_type                     用户物料类型
inventory_item_status_code 物料状态MTL_MATERIAL_TRANSACTIONS表主要字段:
transaction_id 物料事务处理ID
inventory_item_id 项目ID        Revison 版本
organization_id 库存组织ID
subinventory_code 子库存信息
transaction_type_id 事务处理类型ID
transaction_action_id 事务处理行为ID
transaction_source_type_id 事务处理源类型ID
transaction_source_id 事务处理源ID
transaction_source_name 事务处理源名称 
acct_period_id 帐务会计期ID transaction_quantity 事务处理数量
transaction_uom 单位  transaction_date 事务处理日期actual_cost 实际成本
transaction_cost 事务处理成本 currency_code 币种
 主要就是这些表了
希望有人帮我写写,不用我再这里干想

解决方案 »

  1.   

    把表的生成script和測試數據的insert語句貼出 
      

  2.   

    --写一个,不一定正确,自己调试一下
    SELECT a.segment1,
           a.description,
           b.organization_id,
           b.name,
           c.transaction_date,
           c.transaction_type_id
      FROM MTL_SYSTEM_ITEMS_B a, HR_ALL_ORGANIZATION_UNITS b, MTL_MATERIAL_TRANSACTIONS c
     WHERE a.organization_id = b.organization_id AND
           a.organization_id = c.organization_id AND
           b.p_organization_id = '001' AND
           b.date_from >= to_date('2010-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND
           b.date_to <= to_date('2010-01-10 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND
           c.transaction_type_id = '0002'
      

  3.   

    这个不是应该写成函数的形式吗?FUNCTION 或procedure