Getting counts and the sum

2007-01-05 Thread Matt Williams
In SQL, is there an easy way to get the counts of something and then also the total of all those counts? For example, I'm getting the count of times each user has logged in, but I also need the total number for all users. In 2 queries, it would be like so. --For each user... Select userID,

Re: Getting counts and the sum

2007-01-05 Thread Greg Morphis
what DB are you working with, some, like Oracle have a sum(foo) over (partition by goo).. that you could use in this example On 1/5/07, Matt Williams [EMAIL PROTECTED] wrote: In SQL, is there an easy way to get the counts of something and then also the total of all those counts? For example,

Re: Getting counts and the sum

2007-01-05 Thread Matt Williams
On 1/5/07, Greg Morphis [EMAIL PROTECTED] wrote: what DB are you working with, some, like Oracle have a sum(foo) over (partition by goo).. that you could use in this example MSSQL 2005. On 1/5/07, Matt Williams [EMAIL PROTECTED] wrote: In SQL, is there an easy way to get the counts of

RE: Getting counts and the sum

2007-01-05 Thread Dave Watts
MSSQL 2005. Take a look at the WITH CUBE and WITH ROLLUP clauses in T-SQL. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern