[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Aging Report in ORACLE or MSSQL

Posted on 2004-03-26
4
Medium Priority
?
1,302 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 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