Solved

Aging Report in ORACLE or MSSQL

Posted on 2004-03-26
4
1,281 Views
Last Modified: 2012-05-04
Hi all,

I have a bit of a scenario for which I'd really appreciate some help.

I have a database that has client invoices that are churned out on a monthly basis, clients pay against these invoices. However, some clients sometimes don't pay or pay less than the invoiced amounts, some still, pre-pay.

Now, I need to do a debtors aging report showing the distrubution of debts between today (current) and over120 days. I'm able to pull out all my invoiced amounts correctly to allocate them to the correct time bands (30days, 60days, 90days, 120days and over120) but I keep getting errors when it comes to over120 days payments.

Any chance someone has the English query for aging so that I could adapt it to either Oracle or SQL?

Any help offered most appreciated!

Regards,
Gezzat
0
Comment
Question by:Gezzat
[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
4 Comments
 
LVL 2

Accepted Solution

by:
aabbas earned 500 total points
ID: 10693732
Oracle's DECODE function will do this. Following is a simple query to age amount in <30, >=30, >=60, >=90, >=120 days.

select invoice_no, invoice_date, floor (sysdate - invoice_date) "DAYS",
       decode (floor (floor (sysdate - invoice_date) / 30), 0, amt, null) "<30",
       decode (floor (floor (sysdate - invoice_date) / 30), 1, amt, null) ">=30",
       decode (floor (floor (sysdate - invoice_date) / 30), 2, amt, null) ">=60",
       decode (floor (floor (sysdate - invoice_date) / 30), 3, amt, null) ">=90",
       decode (floor (floor (sysdate - invoice_date) / 30), 4, amt, null) ">=120"
from inv;

Above query uses a simple table with Invoice_No, Invoice_Date and Amt columns.

Try it out. Hope, it will work for you.

Best of luck.
0
 

Author Comment

by:Gezzat
ID: 10695020
Thanks Abbas! lemmie try this and get back to you!
0

Featured Post

Independent Software Vendors: 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
Dynamic Table mySQL stored procedure 5 61
How do I search for a text string in my SQL code 18 47
User Prompt in Vertica SQL (vsql) 1 28
Need more granular date groupings 4 42
Creating and Managing Databases with phpMyAdmin in cPanel.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 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