Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Total of your counts in Select Queries

Author  Topic 

lance_carrillo
Starting Member

2 Posts

Posted - 2007-03-19 : 16:09:04
I wrote a simple select query that counts the number of records I have in certain zip codes. How can I get a total of the "count" column at the bottom of the results? For example, my results may look like this:

ZIP | (no column name for "count")
_____________________________________
89502 | 10
89509 | 15
89521 | 25

What statement would I use to get the total of '50' displayed in the resluts? Thank you in advance

-Lance

X002548
Not Just a Number

15586 Posts

Posted - 2007-03-19 : 16:18:37
GROUP BY WITH ROLLUP?

Do you have access to books online?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-03-19 : 16:22:12
Means you want to display 50 at the button of the screen??? then you use compute by clause.

if you just want to get the 50 as result then you have to use sub query..

Give the query through which you got this result, then we may able to help you out..

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-19 : 16:26:02
You also could calculate the footer information in the front-end application.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

lance_carrillo
Starting Member

2 Posts

Posted - 2007-03-19 : 16:26:10
That worked perfectly! Thank you very much. I do have access to books online but very new to SQL and was not sure how to find the answer to this question. I truly appreciate your help!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-19 : 16:33:50
Books Online is installed together with your client tools.
Highlight the keyword in query window and press SHIFT+F1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-03-19 : 16:44:57
it's also online (it better be, that's half the name!) so if you have access to sqlteam.com, you also have access to BOL.

http://msdn2.microsoft.com/en-us/library/ms130214.aspx







www.elsasoft.org
Go to Top of Page
   

- Advertisement -