• smharabbani40 (10/11/2013)


    Hi I need a Query from the month 112013 to 122013 sir......

    i have used the below Query which is not satisfieing.

    SELECT Emp,

    SUM (AMOUNT),

    Monthyear

    FROM table WHERE MonthYear between 112013 and 122013

    GROUP BY Emp

    Sorry to say ,if it very easy thing i wont put in here.

    anyhow thanks for your replay

    That query won't run because you did not also group by Monthyear.

    It seems like Monthyear is an int datatype? If at all possible I would highly recommend changing to a date or datetime datatype instead. It will provide instant validation that the data entered is valid and it will let you do datemath without being forced to cast/convert it first.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/