bs0d
Well-known Member
- Joined
- Dec 29, 2006
- Messages
- 622
I'm building a database that will host financial data by month. I've initially loaded the previous 12 months of history into the database. With each new month, I plan to add no only the new month, but updated versions of perhaps the past ~3 months as well, in the event some trailing costs have been booked. However, assuming the original dates are not removed, this complicates a query to get the most recent previous 12 months of data. This maybe best observed through the example image below:
In the above example, assume it's August, and I'd like the most recent 12 months of data. In August, I would have loaded May-Aug. But the most recent month of April is from the July import, March from the June import, February from the May import... and so on.
How might I query the previous 12 months to acquire the latest data in each month? Somehow it needs to be the max import date for each month between the min and max date selected... Since it's still under construction, advice on better managing this is welcome as well. Maybe to keep things clean, if I add ~3 trailing months, I should delete any historical records for those months as well. The only drawback would be that it would eliminate the possibility of re-creating data that would match prior work.
In the above example, assume it's August, and I'd like the most recent 12 months of data. In August, I would have loaded May-Aug. But the most recent month of April is from the July import, March from the June import, February from the May import... and so on.
How might I query the previous 12 months to acquire the latest data in each month? Somehow it needs to be the max import date for each month between the min and max date selected... Since it's still under construction, advice on better managing this is welcome as well. Maybe to keep things clean, if I add ~3 trailing months, I should delete any historical records for those months as well. The only drawback would be that it would eliminate the possibility of re-creating data that would match prior work.
Last edited: