Is it safe to assume that you are referencing information in the outer select from the inner select statement. If that is the case you will likely need to include those references in the group by clause. SELECT A.Value1, (SELECT B.Value1 FROM TableB B WHERE B.Value2 = A.Value2), SUM(A.Value3) ColumnAlias FROM TableA A GROUP BY A.Value1-- this will fail because A.Value2 is located in the select statement and is not contained within an aggregate or the -- group by clauseSELECT A.Value1, (SELECT B.Value1 FROM TableB B WHERE B.Value2 = A.Value2), SUM(A.Value3) ColumnAlias FROM TableA A GROUP BY A.Value1, A.Value2-- this will work but may give you different results than you were looking for since you ere trying to group by the -- result of the nested select statement
If you are trying to get the select statement to group by the results of that nested select statement, you may need to write the statement so as to remove the nested select in favor of a case statement, or by making a join.