Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

How to write a query to compare Current year fiscal period sales to Last year Fiscal Period sales in SQL Server

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to write a query in SQL server that pulls data from multiple tables and stores it into a new table and I only want the data that compares current year Fiscal period to Last year Fiscal period. 

Any help is greatly appreciated. 

*This post is locked for comments

  • Suggested answer
    Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Super User 2024 Season 1 on at
    RE: How to write a query to compare Current year fiscal period sales to Last year Fiscal Period sales in SQL Server

    Hi NP41,

    Maybe it would be much simpler to just use Management Reporter 2012 to do that work ? it has built-in functions to pull data based on Fiscal periods, so you could compare current period with LY period at the same time, and even add the Budget for that period..

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: How to write a query to compare Current year fiscal period sales to Last year Fiscal Period sales in SQL Server

    You can follow these examples plus use the SQL DateDiff function to separate current and last fiscal years.

    stackoverflow.com/.../how-to-do-a-sum-inside-a-case-statement-in-sql-server

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to write a query to compare Current year fiscal period sales to Last year Fiscal Period sales in SQL Server

    P.S : I already have a table that has fiscal period and year defined so I can just join that table. To be specific, I want to write a query that only gives data for last year fiscal period based on current year fiscal period.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans