Solved

need a specific record from the query

Posted on 2012-03-27
2
328 Views
Last Modified: 2012-03-28
SELECT  
      fbv.book_type_code,
      fdp.period_name,  
      fab.asset_number,
       fab.description,
       fcb.segment1 || '.' || fcb.segment2 asset_category,
       fbv.original_cost original_asset_cost,
       DECODE (fbv.cost, 0, 0, (fbv.cost - fds.deprn_reserve)) net_book_value,
       fds.ytd_deprn,
       fds.deprn_reserve acc_deprn,
       fbv.date_placed_in_service,
       fbv.deprn_method_code,
       (fbv.life_in_months / 12) life_in_years, fds.*
  FROM apps.fa_additions_v fab,
  apps.fa_categories_b fcb,
  apps.fa_books_v fbv,
       fa_deprn_summary fds,
      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 fds.book_type_code = fbv.book_type_code
       and fdp.period_counter=fds.period_counter
       --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 fds.asset_id = fbv.asset_id
      AND  fbv.book_type_code  in  ('TPC US COMP TAX')-- ( 'TPC_US_COMP')--, 'TPC US COMP TAX')
    and asset_number = '39341'
     and fdp.period_name in ( 'Jan-2011', 'Feb-2011', 'Mar-2011', 'Apr-2011', 'May-2011',
      'Jun-2011', 'Jul-2011', 'Aug-2011', 'Sep-2011', 'Oct-2011', 'Nov-2011', 'Dec-2011')
asset-list.txt
0
Comment
Question by:pardeshirahul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:pardeshirahul
ID: 37773692
the output i need only the max of period name records in this case DEC-11 is the max period for other assets it can be different month
0
 
LVL 20

Accepted Solution

by:
gatorvip earned 500 total points
ID: 37773824
Do you need "only the max of period name records" (i.e., the last period)? Or all the records associated with that period?

If the former, then you could do this:

select max( to_date(period_name, 'Mon-YYYY') )
from
...


If the latter, then add a rank() clause to your select:

select *
from
(
select ...
 , rank() over(order by to_date(fdp.period_name, 'MON-YYYY') desc) most_recent
from
...
)
where most_recent=1

Open in new window


Since rank() gives the same value to rows with the same ranking criteria, everything that corresponds to the most recent value in fdp.period_name will have a rank value of 1.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help on model clause 5 47
Problem with duplicate records in Oracle query 16 51
ER Diagram 3 40
Oracle Distributed Transaction Lock Error ORA-01591 8 68
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question