views:

133

answers:

1

I would like to count the number of installations of each Member in a table similar to this. But this count distinct drives me nuts...

MemberID | InstallDate

1 | Yesterday

2 | Today

1 | Today

3 | Today

The above table should produce something like this one..

MemberID | CountNumberOfInstallations

1 | 2

2 | 1

3 | 1

p.s. I know it sound's like homework, but it isnt.

+6  A: 

It looks like the query you are looking for is:

SELECT MemberID, COUNT(*)
FROM Table
GROUP BY MemberID

The DISTINCT keyword is not required. If order is required, you can use:

SELECT MemberID, COUNT(*)
FROM Table
GROUP BY MemberID
ORDER BY MemberID ASC
Roee Adler