Monday, March 12, 2012

Help needed to build "splitted by year totals" query

Hello
I have a table with the following fields
DateFROM
DateTO
Ammount
Storing, you have guessed it, amounts for a period.
My problem is that I will need to split (and prorate) amount per year.
For instance if I have
DateFROM ! DateTO ! Ammount
--
01/jan/04! 31/dec/05! 100
I'd like the query to return two rows
DateFROM ! DateTO ! Ammount
--
01/jan/04! 31/dec/04! 50
01/jan/05! 31/dec/05! 50
Ideally I'd need to account for bissextile years...
Any idea how to achieve this. Definitely too complex for me :)
Thanks & regards
--alexTUsing a calendar table would solve this issue quite easily. Build one for
the required duration and use it in your query involving the JOIN. If you
need a specific query, refer to: www.aspfaq.com/5006 and post required
information for others to repro your problem.
Anith

No comments:

Post a Comment