Friday, 18 November 2016

Fixed Asset detail query

/* Formatted on 11/18/2016 2:17:55 PM (QP5 v5.114.809.3010) */
SELECT   DISTINCT
         fab.description,
         fcb.segment1 majorcategory,
         fcb.segment2 minor_category,
         fcb.segment3 subminor,
         fab.current_units units,
         fbv.COST asset_cost,
         fbv.original_cost,
         fab.asset_number,
         NVL (
            (SELECT   deprn_amount
               FROM   fa_deprn_detail
              WHERE   asset_id = fab.asset_id AND deprn_source_code = 'D'),
            0
         )
            deprn_amount,
         fbv.COST
         - NVL (
              (SELECT   deprn_amount
                 FROM   fa_deprn_detail
                WHERE   asset_id = fab.asset_id AND deprn_source_code = 'D'),
              0
           )
            nbv_value,
         fl.segment1 country,
         fl.segment2 region,
         fl.segment3 wilatay,
         fl.segment4 sbu,
         fl.segment5 cost_centre,
         fl.segment6 lasset_location,
            gcc.segment1
         || '.'
         || gcc.segment2
         || '.'
         || gcc.segment3
         || '.'
         || gcc.segment4
         || '.'
         || gcc.segment5
         || '.'
         || gcc.segment6
         || '.'
         || gcc.segment7
         || '.'
         || gcc.segment8
            expense_account,
         NULL clearing_account,
         fbv.date_placed_in_service,
         fbv.prorate_date,
         'STL' depreciationmethod,
         fbv.life_in_months lifeinmonths,
         fab.asset_type,
         (SELECT   segment1 || '.' || segment2
            FROM   fa_asset_keywords
           WHERE   code_combination_id = fab.asset_key_ccid AND ROWNUM = 1)
            asset_key
  FROM   apps.fa_additions_v fab,
         apps.fa_books_v fbv,
         apps.fa_categories_b fcb,
         apps.fa_deprn_periods fdp,
         apps.fa_distribution_history fdh,
         apps.gl_code_combinations gcc,
         apps.fa_locations fl
 WHERE       1 = 1
         AND fab.asset_id = fbv.asset_id
         AND fcb.category_id = fab.asset_category_id
         AND fbv.transaction_header_id_out IS NULL
         AND fdp.book_type_code = fbv.book_type_code
         AND fdh.asset_id = fbv.asset_id
         AND fdh.code_combination_id = gcc.code_combination_id
         AND fdh.location_id = fl.location_id
         AND fbv.transaction_header_id_out IS NULL
         AND fdh.transaction_header_id_out IS NULL
--and fbv.date_placed_in_service!=fbv.PRORATE_DATE
--and fbv.COST! =fbv.ORIGINAL_COST
--and fab.asset_number like '%TEST%'

No comments:

Post a Comment