Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there way that I can get the sum of a column in my query result set by just clicking on the column (something like in excel) so that i don't have to copy and paste the column into excel to the see the total sum of all the values in the column?

I'm running SQL Server 2008

share|improve this question
I dont think it is possible. – Jackofall Mar 13 '12 at 13:46
You might want to upvote one of Aaron Bertrand's connect items although the comments thread doesn't inspire much hope. – Martin Smith Mar 13 '12 at 14:00
@MartinSmith Thanks! – PokerPlayer23 Mar 13 '12 at 14:38
up vote 8 down vote accepted

Use the OVER clause to modify a SUM scope in your query. No GROUP BY needed

    MyColumn, OtherColumn,
    SUM(MyColumn) OVER () AS SumTotal

Otherwise, SSMS isn't a calculating engine: it display query results so add it to your query...

share|improve this answer
Curious, will that give me the sum if I click one of the column in query result. I think it is not possible. – Jackofall Mar 13 '12 at 13:46
@Jackofall No, that's not what SSMS is for. You need to do this through T-SQL as specified by gbn. It is not possible using the GUI. – Thomas Stringer Mar 13 '12 at 13:46
the op asked just clicking on the column (something like in excel), that means he wants to click on a column header and it should give him the sum – Jackofall Mar 13 '12 at 13:49
@Jackofall: As I said, this can't be done unless you add it to the query... – gbn Mar 13 '12 at 14:18
@gbn Thanks! I just tried it and it worked. Beats having to switch over to excel and copying and pasting columns. The fact that I don't have to group by all the other columns is the best part. – PokerPlayer23 Mar 13 '12 at 20:15

You can use GROUP BY and SUM of particular column value.

SELECT EmployeeName, SUM(Salary)
  FROM YourTable
  GROUP BY EmployeeName
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.