SQL sort by sum of two different where clauses in a join
i would be tempted to write something like below to pivot sum. 

Query

SELECT 
   table1.Name 
 , SUM(CASE WHEN table2.Values = 1 THEN 1 ELSE 0 END) AS "s1"
 , SUM(CASE WHEN table2.Values = 2 THEN 1 ELSE 0 END) AS "s2"
 , SUM(CASE WHEN table2.Values = 3 THEN 1 ELSE 0 END) AS "s3"
FROM 
 table1
INNER JOIN
 table2 
ON
 table1.ID = table2.table1ID
GROUP BY 
 table1.Name