0

I have a sql query that is outputting:

col1    col2
A        1
B        3
C        4
D        5

Is there a way to add a column where it outputs the sum of all the numbers in col2?

col1    col2  col3
A        1     13
B        3     13
C        4     13
D        5     13

1 Answer 1

1

You can use window functions:

select col1, col2, sum(col2) over () as col3
from t;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.