<p>I have one field that I need to sum lets say named items
However that field can be part of group a or b
In the end I need to have all of the items summed for group a and group b</p>

<p>when I say grouped I mean there is a LEFT OUTER JOIN to another table the previous table has a type for the items and the one being joined has a group assigned for this item type</p>

<p>Sorry guys Im a little new to sql I am going to try out what you have given me an get back to you</p>

<p>Ok I feel like we are getting close just not yet allain's I can get them to separate but the issue I need to have both groups to sum on the same row which is difficult because I also have several LEFT OUTER JOIN's involved</p>

<p>Tyler's looks like it might work too so I am trying to hash that out real fast</p>

<p>Alain's seems to be the way to go but I have to tweek it a little more</p>

[{'answer_id': 30578, 'author': 'Allain Lalonde', 'author_id': 2443, 'author_profile': 'https://Stackoverflow.com/users/2443', 'pm_score': 3, 'selected': True, 'text': "<p>Maybe I'm not understanding the complexity of what you're asking but... shouldn't this do?</p>\n\n<pre><code>SELECT groupname, SUM(value)\nFROM items\nWHERE groupname IN ('a', 'b')\nGROUP BY groupname\n</code></pre>\n\n<p>And if you don't care which of a or b the item belongs to then this will do:</p>\n\n<pre><code>SELECT SUM(value)\nFROM items\nWHERE groupname IN ('a', 'b')\n</code></pre>\n"}, {'answer_id': 30579, 'author': 'FreeMemory', 'author_id': 2132, 'author_profile': 'https://Stackoverflow.com/users/2132', 'pm_score': 0, 'selected': False, 'text': '<p>You want something like</p>\n\n<pre><code>SELECT column,SUM( column ) FROM table GROUP BY column\n</code></pre>\n'}, {'answer_id': 30584, 'author': 'Leigh Caldwell', 'author_id': 3267, 'author_profile': 'https://Stackoverflow.com/users/3267', 'pm_score': 0, 'selected': False, 'text': "<p>Is that (Tyler's answer) what the question meant, or is it simply this;</p>\n\n<pre><code>SELECT sum(item), groupingField FROM someTable GROUP BY groupingField\n</code></pre>\n\n<p>or even:</p>\n\n<pre><code>SELECT count(*), item FROM someTable GROUP BY item\n</code></pre>\n\n<p>which will produce results like this:</p>\n\n<pre><code>sum(item)    |     groupingField\n-------------+-----------------------\n 71          |          A\n 82          |          B\n</code></pre>\n\n<p>Questioner, perhaps you could clarify which you meant or if I'm oversimplifying?</p>\n"}, {'answer_id': 30704, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 0, 'selected': False, 'text': '<p>Try this:  </p>\n\n<pre><code>SELECT B.[Group], COUNT(*) AS GroupCount\nFROM Table1 A\nLEFT JOIN Table2 B ON B.ItemType=A.ItemType\nGROUP BY B.[Group]\n</code></pre>\n'}, {'answer_id': 59008474, 'author': 'Senthuran', 'author_id': 8563654, 'author_profile': 'https://Stackoverflow.com/users/8563654', 'pm_score': -1, 'selected': False, 'text': '<p>Please refer this Image (<a href="https://i.stack.imgur.com/5R9ou.png" rel="nofollow noreferrer">1</a>)</p>\n\n<pre><code>SELECT category_id,SUM(amount) AS count  FROM expense GROUP BY category_id;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/30563', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2486/']