• smharabbani40 (10/11/2013)


    Hi ALL,

    I have one table which contines 3 columns they are

    1.emp

    2.monthyear

    3.amount

    in that table i am having four rows like below.

    emp monthyear amount

    1 112013 1000

    1 112013 1000

    2 122013 1000

    2 122013 0000

    i want a total on group by condition on each employee.

    out put should be like this

    1 2000

    2 1000

    This looks a lot like homework. You will need to use SUM.

    http://technet.microsoft.com/en-us/library/ms187810.aspx

    _______________________________________________________________

    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/