Sum query 12 month in year

  • Hello guys, i have table like blue area, how to query get result like green area

    Untitled

  • For a question like this, you help yourself quite a bit if you post CREATE TABLE statements for your table(s), INSERT statements with sample data and the desired result from that sample data. You should also include a short description of the business rules to explain why you want that particular result.

    Having CREATE TABLE + INSERT permits to copy and paste into a query window to develop a tested query. We cannot copy from a screenshot. The expected results can be a screenshot though.

    The business rules are also needed so that we understand what you are looking for. Else we would have to guess, and we may guess wrong, which is frustrating for everyone involved.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • You've been here for a while...

    Surely you know how to post consumable data.

    When I copied and pasted your pictures into SSMS, it wouldn't execute them... so I don't know how to help.

  • mrsiro wrote:

    Hello guys, i have table like blue area, how to query get result like green area

    Untitled

    Just in case you don't know what people are talking about, please read the article at the first link in my signature line below.  It'll really help us help you.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply