Wednesday, 19 February 2014

SQL Script to get invoice ship to use id and respsctive order ship to use id

select distinct trx.customer_trx_id
          ,hca.cust_account_id
          ,trx.trx_number
          ,case trx_lines.SALES_ORDER_SOURCE
                when 'ORDER ENTRY' then
                (select ship_to_org_id from apps.oe_order_lines_all where
                line_id=trx_lines.interface_line_attribute6)
                else
                null
end order_ship_to_use_id
,trx.SHIP_TO_site_use_id invoice_ship_to_use_id
   from ra_customer_trx_all trx
        ,hz_cust_accounts_all hca
        ,ra_customer_trx_lines_all trx_lines
         where hca.cust_account_id=trx.ship_to_customer_id
   and trx_lines.customer_trx_id=trx.customer_trx_id
   and TRX_LINES.INTERFACE_LINE_ATTRIBUTE1 is not null
   and trx.org_id=2661
   and trx_number='1000089'
      ;

No comments:

Post a Comment