Link to home
Start Free TrialLog in
Avatar of smantz
smantzFlag for United States of America

asked on

Counting a particular number of instances of a record




I am trying to create a query that allows me find individuals who have two or more instances of a particular record for them where the field value =1234.
Any ideas and I may need to elaborate if this is not clear?  MS Sql 2000 is the DB
ASKER CERTIFIED SOLUTION
Avatar of Simone B
Simone B
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smantz

ASKER

Worked great but needed to change last, "count (individual)" to Count(fieldvalue)
Thanks
Avatar of Scott Pletcher
Select
    individual,
    sum(case when fieldvalue = 1234 then 1 else end) AS [1234_count]
    --, sum(case when fieldvalue is null or fieldvalue <> 1234 then 1 else end) AS [other_count]
from
    table_name
group by individual
having sum(case when fieldvalue = 1234 then 1 else end) > 1