Q:

SQL, add column with summed values of the same type

My current table looks like this:
ID   TYPE   QUANTITY   
1    A1     3
2    B1     2
3    A1     2
4    B1     8

And after doing the query I want to get that:
ID   TYPE   QUANTITY   SUM   
1    A1     3          5
2    B1     2          10
3    A1     2          5
4    B1     8          10

The SUM column consist of summed quantities of items with the same type. 

A:

SELECT t.ID,t.TYPE,t.QUANTITY,x.SUM FROM TABLE t LEFT JOIN
(SELECT ID,TYPE,QUANTITY,SUM(QUANTITY) AS SUM FROM TABLE GROUP BY TYPE)x
ON t.type=x.type 

SQL Fiddle

