The query is not running. May be there is some date formatting issue.
Main Topics
Browse All TopicsI am trying to create a liability aging report for Oracle Payables. The report shall give details of invoices for which any amount is payable as on a given date. I have created the query which is giving correct results.
However I need help on how to create the aging buckets. 0-90 days; 91-180 days; 181-365 days; More than 365 days.
The query I am using is attached herewith.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
select invoice_id,sum(accounted_c
CASE WHEN to_char(accounting_date,'d
CASE WHEN to_char(accounting_date,'d
CASE WHEN to_char(accounting_date,'d
CASE WHEN to_char(accounting_date,'d
CASE WHEN to_char(accounting_date,'d
from apps.ap_liability_balance
where code_combination_id = 'XXXXX' and
accounting_date <= '30-JUN-2009' and
org_id ='XXX'
having sum(accounted_cr) - sum(accounted_dr) <>0
group by invoice_id
try this
--------------------------
may be problem with this line
CASE WHEN accounting_date < ADD_MONTHS ('30-JUN-2009', -12) then (accounted_cr) - sum(accounted_dr) else 0 end amount_abvoe365_days,
it should be like this
I don't think that the query posted above will work, as it will raise an ORA-00979: "not a GROUP BY expression" since it's referencing ACCOUNTING_DATE, which isn't in the GROUP BY clause. Also do you want multiple columns for the buckets? - I suspect it would be more useful to have the value in a single column.
If you want to create the aging buckets, based on the accounting date, then try something like the following, which will give you the bucket in a single column :
Business Accounts
Answer for Membership
by: shru_0409Posted on 2009-08-17 at 08:26:29ID: 25115369
select invoice_id,sum(accounted_c r) - sum(accounted_dr) Amount cr) - sum(accounted_dr) else 0 end amount_abvoe365_days,
CASE WHEN accounting_date > ADD_MONTHS ('30-JUN-2009', -3) and accounting_date < '30-JUN-2009' then sum(accounted_cr) - sum(accounted_dr) else 0 end amount90_days,
CASE WHEN accounting_date > ADD_MONTHS ('30-JUN-2009', -6) and accounting_date< ADD_MONTHS ('30-JUN-2009', -3) then sum(accounted_cr) - sum(accounted_dr) else 0 end amount180_days,
CASE WHEN accounting_date > ADD_MONTHS ('30-JUN-2009', -9) and accounting_date< ADD_MONTHS ('30-JUN-2009', -6) then sum(accounted_cr) - sum(accounted_dr) else 0 end amount180_days,
CASE WHEN accounting_date > ADD_MONTHS ('30-JUN-2009', -12) and accounting_date< ADD_MONTHS ('30-JUN-2009', -9) then sum(accounted_cr) - sum(accounted_dr) else 0 end amount365_days,
CASE WHEN accounting_date < ADD_MONTHS ('30-JUN-2009', -12) then accounting_date(accounted_
from apps.ap_liability_balance
where code_combination_id = 'XXXXX' and
accounting_date <= '30-JUN-2009' and
org_id ='XXX'
having sum(accounted_cr) - sum(accounted_dr) <>0
group by invoice_id