title: Using the Group By statement
body: <p>I am trying to deploy a table in SSRS by using group by only <code>Symbol</code> and <code>region</code> and don't want to group by Trade because I am get incorrect results. I've used the following code : </p>
  
  <pre><code>SELECT Symbol, Region, Trade, SUM(Profit) AS Total
  FROM dbo.[15 Mins]
  GROUP BY Symbol 
  HAVING SUM(Profit)&lt;0
  </code></pre>
  
  <p>The report says Column 'dbo.15 Mins.Trade' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</p>
  
  <p>Well what I want is to group the Negative Sum(Profit) only by the symbols and say when I click the plus sign on the SSRS report, it further drills down and shows the detailed data : Symbol- Region- Trade - Profit of each trade.</p>
  
  <p>Eg.</p>
  
  <pre><code>SYMBOL  REGION TRADE PROFIT
  
  Apple   NYSE   BUY   100  
  Apple   NYSE   BUY   -200
  MSFT    NYSE   BUY   300
  MSFT    NYSE   SELL  500
  </code></pre>
  
  <p>so basically what I want in SSRS :</p>
  
  <p>1) get symbols which have a negative sum(profit) </p>
  
  <pre><code>SYMBOL  REGION TRADE SUM(Profit)
  (+)Apple                -100  
  </code></pre>
  
  <p>After I press the (+) sign the table expands and shows me the following :</p>
  
  <pre><code>SYMBOL  REGION TRADE SUM(Profit)
  Apple   NYSE   BUY   100  
  Apple   NYSE   BUY   -200
  </code></pre>