Re: Counting times each element appears
- From: "Mark A. Parsons" <user@xxxxxxxxxxx>
- Date: Sun, 22 Jan 2006 18:45:36 GMT
Need to leave out the 'distinct' else you get '1' as a count() for all records in the result set.
================================== 1> select foo, 2> count(distinct foo) 3> from foobar 4> group by foo 5> go
foo
----------- -----------
1 1
2 1
3 1
4 1(4 rows affected) ================================== 1> select foo, 2> count(foo) 3> from foobar 4> group by foo 5> go
foo
----------- -----------
1 6
2 5
3 4
4 3(4 rows affected) ==================================
--CELKO-- wrote:
SELECT Foo, COUNT (DISTINCT foo ) FROM Foobar GROUP BY Foo;
.
- References:
- Counting times each element appears
- From: aizenman
- Re: Counting times each element appears
- From: --CELKO--
- Counting times each element appears
- Prev by Date: Re: sp_hidetext
- Next by Date: Re: sum i database
- Previous by thread: Re: Counting times each element appears
- Next by thread: sp_hidetext
- Index(es):