JimiJ13
asked on
Invoice Aging based on Term
Dear Experts,
I am looking for a new and efficient way of dynamic reporting of Aging Invoices using SQL 2012 -up.
I would appreciate anyone who can share one that can be applied on the attached sample.
Thanks.
I am looking for a new and efficient way of dynamic reporting of Aging Invoices using SQL 2012 -up.
I would appreciate anyone who can share one that can be applied on the attached sample.
Thanks.
ASKER
ASKER
Sales Table
Columns: CustomerID, Due Amount, Date, Term
Expected Output: Current, over15, Over30, Over60, Over75, Over90, Over120
Thanks.
Columns: CustomerID, Due Amount, Date, Term
Expected Output: Current, over15, Over30, Over60, Over75, Over90, Over120
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi ScottPletcher,
That looks good and very clean. Can you revise it to consider the age counting after the Term (Number of days)?
Thanks.
That looks good and very clean. Can you revise it to consider the age counting after the Term (Number of days)?
Thanks.
>>"consider the age counting after the Term"
can you explain what you mean by providing an example?
(don't assume we understand your words)
and, don't forget to tell use where we get "after the term" from?
(i.e. in the sample data I dob't see anything more then one date column)
can you explain what you mean by providing an example?
(don't assume we understand your words)
and, don't forget to tell use where we get "after the term" from?
(i.e. in the sample data I dob't see anything more then one date column)
ASKER
Hi Paul,
If the customer has a term of 30 days, that means the aging will only start on the 31st day and counting onward. However, if the term is zero (o) day, the aging starts immediately. So the current is equals to Term + 15 days from date of Sales transaction.
I hope that makes sense.
Thanks.
If the customer has a term of 30 days, that means the aging will only start on the 31st day and counting onward. However, if the term is zero (o) day, the aging starts immediately. So the current is equals to Term + 15 days from date of Sales transaction.
I hope that makes sense.
Thanks.
There really is a reason for asking you to explain "using examples"
words alone are never as good for an explanation as fully worked examples
try amending the code by Scott by deducting term. i.e.
CROSS APPLY (
SELECT DATEDIFF(DAY, tn.Date, GETDATE()) - [Term] AS days_old
) AS assign_alias_names
But somehow I doubt that is what you really want.
EXAMPLES please
words alone are never as good for an explanation as fully worked examples
try amending the code by Scott by deducting term. i.e.
CROSS APPLY (
SELECT DATEDIFF(DAY, tn.Date, GETDATE()) - [Term] AS days_old
) AS assign_alias_names
But somehow I doubt that is what you really want.
EXAMPLES please
ASKER
ASKER
ScottPletcher,
I tried your solution with the Test table sample and it has an error as shown in the attachment.
Any idea?
Thanks.SampleSales-0818.sql
I tried your solution with the Test table sample and it has an error as shown in the attachment.
Any idea?
Thanks.SampleSales-0818.sql
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great! Thank you very much Paul & ScottPletcher for a very professional solution.
oh & please note that currently there is a 40 character limit on filenames (including extension)