• Why are you storing productions as varchar? Do you expect non numeric values?

    How do you compare results for previous month and previous year?

    You should review your requirements for the report, it makes no sense if the amount of rows for current month, previous month and previous year don't match.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2