Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kdeutsch
Yak Posting Veteran
83 Posts |
Posted - 2009-11-09 : 10:57:39
|
| I have a table where a person can have multiple personnel problems but I only want to count one of the records that is in a critical status, no more. so if a person has 10 critical tasks the count would be one against them and not 10. here is my current count and it bring s up 14 as the count, but that is not correct and should only bring up 5 becasue there are 5 people assigned but they each have multiple critical tasks.Select distinct Count(pt.strTaskName), pt.strSSN, pt.strnamefrom tblpermTask as pt INNER JOIN tblFilter as f on f.intFilterID = pt.intFilterID INNER JOIN tblUnitPersonnel as up on up.strSSN = pt.strSSN INNER JOIN tblUnitPosition as p on p.intPositionId = up.intPositionIDwhere f.strPriority = 'Critical' and p.intUnitMObID = 458 and pt.dtCompleted IS NULLGroup by pt.strSSN, pt.strname |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-11-09 : 11:01:05
|
| try Select Count(distinct pt.strname),... |
 |
|
|
|
|
|