Take the 2-minute tour ×
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. It's 100% free, no registration required.

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! –  JuanVelez Mar 13 '12 at 14:38

1 Answer 1

up vote 4 down vote accepted

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

SELECT
    MyColumn, OtherColumn,
    SUM(MyColumn) OVER () AS SumTotal
FROM
    ...

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
1  
@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. –  JuanVelez Mar 13 '12 at 20:15

Your Answer

 
discard

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.