Skip to Content

Hello SCN need your help regarding Year and Month conflict in my data

Hi all,

                I have data in a table with few days of previous year data and this year data and it was working fine until December 2014 but when the year changed to 2015 my report started showing zero values .After investigating I found that there is some data from Dec 2014 with last three days of the year .

The SQL script is something like this.


This script worked fine when Month was increasing with same year but when year increased by one and month decreased from 12 to 01 this script failed to show current year data instead it was showing this.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 20, 2015 at 09:01 AM

    Seriously, I really don't understand how your table or your data looks like.

    It's just not in your problem statement.

    Anyhow, the SQL you posted selects two independent information:

    The highest value for MONTH and the highest occurring YEAR in your table.

    I *guess* (I have to, since you did not tell us, what you actually wanted to do) that you wanted the month and year component of the "highest" date value in your table.

    If that's correct, the statement rather should be this:

    SELECT month( max(SLS_DATE)) as max_date_month

              , year( max(SLS_DATE)) as max_date_year

    FROM ...

    - Lars

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 20, 2015 at 01:11 PM

    Thanks Lars,

                        Though you didn't understood what's in my table ,your general guess was correct your Select statement worked for me.



    Add comment
    10|10000 characters needed characters exceeded