all groups > sql server programming > september 2007 >
You're in the

sql server programming

group:

How to get a total sum



Re: How to get a total sum Roy Harvey (SQL Server MVP)
9/24/2007 4:22:46 PM
sql server programming: SELECT COUNT(IPAddress) AS Hits
FROM Hits_ThirdQuarterVideo

Roy Harvey
Beacon Falls, CT

On Mon, 24 Sep 2007 20:17:28 GMT, "zwieback89 via SQLMonster.com"
[quoted text, click to view]
Re: How to get a total sum Jim Underwood
9/24/2007 4:29:21 PM
lookup "WITH ROLLUP", it outputs summary data for each column in your group
by.

SELECT DateAccessed
, COUNT(IPAddress) AS Hits
FROM Hits_ThirdQuarterVideo
GROUP BY DateAccessed WITH ROLLUP

[quoted text, click to view]

How to get a total sum zwieback89 via SQLMonster.com
9/24/2007 8:17:28 PM
Hi,

I have a query that shows a total number of hits for each day. The query is:

SELECT DateAccessed, COUNT(IPAddress) AS Hits
FROM Hits_ThirdQuarterVideo
GROUP BY DateAccessed

My question now is how to get the total sum of all the counts per day? Is
this possible to do so in SQL statement?

Thanks.

--
---------------------
zwieback89

Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/200709/1
Re: How to get a total sum Mr Tea
9/24/2007 8:26:10 PM
Can you get away with a compute ?

SELECT DateAccessed, COUNT(IPAddress) AS Hits
FROM Hits_ThirdQuarterVideo
GROUP BY DateAccessed
COMPUTE SUM(COUNT(IPAddress))

Mr Tea

[quoted text, click to view]

Re: How to get a total sum zwieback89 via SQLMonster.com
9/24/2007 9:05:41 PM
Roy,

This query will just return the number of rows for the the column, IPAddress
and not the number of hits per day.

Thanks,

[quoted text, click to view]

--
---------------------
zwieback89

Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/200709/1
Re: How to get a total sum zwieback89 via SQLMonster.com
9/24/2007 9:10:21 PM
This solution worked for me. However I need to find a way to access only that
grand count value in my ASP variable to show on the web-site.

Thanks for your time in posting a solution.

- Padmaja.

[quoted text, click to view]

--
---------------------
zwieback89

Message posted via http://www.sqlmonster.com
Re: How to get a total sum zwieback89 via SQLMonster.com
9/24/2007 9:15:32 PM
Hi Jim,

Thanks for the solution. It worked for me.

- zwieback89

[quoted text, click to view]

--
---------------------
zwieback89

Message posted via http://www.sqlmonster.com
Re: How to get a total sum Dieter Noeth
9/25/2007 8:06:59 AM
[quoted text, click to view]

If you want that output as an extra column (SS2005):

SELECT DateAccessed, COUNT(IPAddress) AS Hits,
sum(COUNT(IPAddress)) over () as Total_hits
FROM Hits_ThirdQuarterVideo
GROUP BY DateAccessed

AddThis Social Bookmark Button