Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    11

    Unanswered: Sum plus Group By

    I have not written a query in a couple years so my skills are rusty. I have table with 5 columns LOCATION TAG_Target TAG_Submitted TAG_Actual DATE
    please take a look at Graph below so im trying to get something similar how many actual tags by location by month. I got as far as the script below but how do i get the by month part?

    SELECT site, sum (cast (Tags_Actual_Cleared as int))
    FROM QLY
    group by site


    Click image for larger version. 

Name:	graph.PNG 
Views:	4 
Size:	33.5 KB 
ID:	16542


    Thanks for any help you can provide.

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    You could start by adding TAG_Actual to your GROUP BY and SELECT. However what I think you are after is the PIVOT command...

    For information on PIVOT see this....

    https://technet.microsoft.com/en-US/...=SQL.105).aspx
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •