WITH SUMS AS
(
SELECT
col1, col2,
SUM(col1) + SUM(col2) as Total,
SUM(col1) + SUM(col2) as Total1
FROM
table
GROUP BY
col1, col2
)
SELECT
col1, col2,
total, total1,
(total + total1) AS 'GrandTotal'
FROM
SUMS
Last active
April 27, 2023 17:44
-
-
Save vwedesam/c4a9474960958274998573e78b69ce82 to your computer and use it in GitHub Desktop.
SQL Re-Use alias named columns
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment