Home » Applications » Oracle Fusion Apps & E-Business Suite » Latest Row (11i)
Latest Row [message #472995] Wed, 25 August 2010 04:45 Go to next message
yknev
Messages: 38
Registered: August 2010
Member
Hi,

How to find the latest row(sigle row) using fa_distributin_history and fa_deprn_detail.

I want columns like below from above two tables


fdh.distribution_id  fdh.locaton_id fd.ytd_deprn  fd.deprn_amount



Thanks & Regards,

Yknev
Re: Latest Row [message #473007 is a reply to message #472995] Wed, 25 August 2010 06:32 Go to previous messageGo to next message
Alien
Messages: 292
Registered: June 1999
Senior Member
Hi,

it depends on your requirement for assets that have not been depreciated yet.
I think the following should get you started:

select fdh.distribution_id, fdh.location_id, fd.ytd_deprn, fd.deprn_amount
from (select row_number() over (partition by dist.book_type_code,dist.asset_id 
                                order by dist.date_effective desc) rn
      ,      dist.book_type_code
      ,      dist.asset_id
      ,      dist.distribution_id
      ,      dist.location_id
      from   fa_distribution_history dist) fdh
,    (select row_number() over (partition by dd.asset_id, dd.book_type_code 
                                order by period_counter desc) rn
      ,      ytd_deprn
      ,      deprn_amount
      ,      asset_id
      ,      book_type_code
      ,      distribution_id
      from   fa_deprn_detail dd) fd
where fd.distribution_id = fdh.distribution_id
and   fd.book_type_code = fdh.book_type_code -- Not required, after the join on distribution_id
and   fd.asset_id = fdh.asset_id             -- But it allows the optimizer a better cardinality estimate.
and   fdh.rn=1
and   fd.rn=1;


Regards,

Arian
Re: Latest Row [message #473047 is a reply to message #473007] Wed, 25 August 2010 10:18 Go to previous messageGo to next message
eric62
Messages: 24
Registered: January 2009
Junior Member

Hi.

You can't join
fd.book_type_code = fdh.book_type_code

In fa_distribution_history, the book is always corporate book.

So if you want data for tax book, you won't find it.

Re: Latest Row [message #473055 is a reply to message #473047] Wed, 25 August 2010 11:01 Go to previous messageGo to next message
Alien
Messages: 292
Registered: June 1999
Senior Member
Hi,

that's why I put the comment. It's still a valid join, but it depends on your requirements.
And I think OP will use this as part of a larger query.

Regards,

Arian
Re: Latest Row [message #473122 is a reply to message #473055] Thu, 26 August 2010 02:38 Go to previous messageGo to next message
eric62
Messages: 24
Registered: January 2009
Junior Member
Hello.

Use of fa_books for the join on book_type_type and asset_id
is a good idea ?

Regards,
Eric.
Re: Latest Row [message #473390 is a reply to message #473122] Fri, 27 August 2010 14:18 Go to previous messageGo to next message
Alien
Messages: 292
Registered: June 1999
Senior Member
Hi,

good point.
I think you'll need FA_BOOKS in your queries as soon as you use multiple books (or possibly will in the future).
FA_BOOKS is the only source to decide which books to query, and therefore the only source of the book_type_code.

Regards,

Arian
Re: Latest Row [message #473865 is a reply to message #473390] Wed, 01 September 2010 04:39 Go to previous messageGo to next message
yknev
Messages: 38
Registered: August 2010
Member
Hi Alien,

Using above query. How to restrict the Remaining months is reaching to zero.i.e we don't want once the asset is expired(service of asset is completed).

Regards,
Yknev.

[Updated on: Wed, 01 September 2010 05:45]

Report message to a moderator

Re: Latest Row [message #473885 is a reply to message #473865] Wed, 01 September 2010 07:30 Go to previous messageGo to next message
eric62
Messages: 24
Registered: January 2009
Junior Member
Hello

You have to use FA_BOOKS.

- with you asset_Id (FA_BOOOKS.ASSET_ID = Your asset_id)
- with your book ( FA_BOOOKS.BOOK_TYPE_CODE = Your book) if you select a book
- The effective Record (FA_BOOOKS.TRANSACTION_HEADER_ID_OUT IS NULL)
- Asset not completely expired (FA_BOOOKS.PERIOD_COUNTER_FULLY_RESERVED IS NULL )
- Asset not completely retired (FA_BOOOKS.PERIOD_COUNTER_FULLY_RETIRED IS NULL )

Regards
Eric.
Re: Latest Row [message #473892 is a reply to message #473885] Wed, 01 September 2010 08:19 Go to previous message
yknev
Messages: 38
Registered: August 2010
Member
Hello Eric,

Thanks, it's helpful to me.

Regards,
Yknev
Previous Topic: Oracle Financial Functional Spec
Next Topic: Limit on price list lines in Oracle Price lists
Goto Forum:
  


Current Time: Mon Dec 23 12:46:17 CST 2024