役に立つかもしれない定数でグループ化できます
SELECT SUM(Column0), CASE @MyVar WHEN 'Column1' THEN Column1 ELSE '' END AS MyGrouping FROM Table1 GROUP BY CASE @MyVar WHEN 'Column1' THEN Column1 ELSE '' END
プレ>編集:データ型の不一致と複数の値の場合、これにより両方の列でグループ化できます...
SELECT SUM(Column0), CASE @MyVar WHEN 'Column1' THEN Column1 ELSE NULL END AS Column1, CASE @MyVar WHEN 'Column2' THEN Column2 ELSE NULL END AS Column2 FROM Table1 GROUP BY CASE @MyVar WHEN 'Column1' THEN Column1 ELSE NULL END, CASE @MyVar WHEN 'Column2' THEN Column2 ELSE NULL END
プレ>