Link to home
Start Free TrialLog in
Avatar of Malinda Klein
Malinda Klein

asked on

How to filter out rows with more than 1 group?

In SSRS, I want to filter out only those employees with more than 1 partfile number.  

My query is

Select e.name,
            p.pfnumber from employees as e
left join partfile as p
on p.recid=e.partfilerecid
group by e.name

What expression do I use in the filter to be > 1?
Avatar of Malinda Klein
Malinda Klein

ASKER

SSRS won't accept Count(e.partfilerecid) > 1
Avatar of Scott Pletcher
Select e.name,
            max(p.pfnumber) as pfnumber
from dbo.employees as e
left join dbo.partfile as p
on p.recid=e.partfilerecid
group by e.name
having count(*) <= 1
Actually I was wanting to filter out those employees that have two or more pfnumbers so I need to count the number of pfnumbers and only display those that have two or more.  But SSRS won't let me list an aggregate in the expression.
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America 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
SOLUTION
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