Monday, 3 February 2014

periods open and Close query

Query-1
------------
select e.organization_name
         ,e.ORGANIZATION_CODE organization_code
         ,oap.period_name present_open_period
         ,oap1.period_name last_open_period
 from (select oap.organization_id,
       ood.organization_name,
       ood.ORGANIZATION_CODE,
       max(ACCT_PERIOD_ID) present_open,
       min(ACCT_PERIOD_ID) last_open
from ORG_ACCT_PERIODS oap,
org_organization_definitions ood
where oap.ORGANIZATION_ID=ood.organization_id
and OPEN_FLAG='Y'
group by oap.ORGANIZATION_ID,ood.organization_name,ood.ORGANIZATION_CODE) e,org_acct_periods oap,
org_acct_periods oap1
where oap.acct_period_id=e.present_open
and oap.organization_id=e.organization_id
and oap1.acct_period_id=e.last_open
and oap1.organization_id=e.organization_id--,oap.period_name
order by e.organization_name

Query2
-----------------
select fat.application_id
       ,fat.application_id app_id
      ,fat.application_name app_name
      ,fat.application_name
      ,gps.period_name present_open_period
      ,gps1.period_name last_open_period
from gl_period_statuses gps
     ,gl_period_statuses gps1
     ,fnd_application_tl fat
     ,(select  application_id
              ,max(EFFECTIVE_PERIOD_NUM) max_e_p_num
              ,min(EFFECTIVE_PERIOD_NUM) min_e_p_num
               from gl_period_statuses
               where APPLICATION_ID in (101,200,201,222)
               and CLOSING_STATUS='O' group by application_id) a
where gps.application_id=fat.application_id
and   a.application_id=gps.application_id
and   gps.EFFECTIVE_PERIOD_NUM=a.max_e_p_num
and   gps1.application_id=a.application_id
and   gps1.EFFECTIVE_PERIOD_NUM=a.min_e_p_num
--and   gps1.CLOSING_STATUS='O'
order by application_name


No comments:

Post a Comment