This is an easy way to do it:
SELECT DISTINCT SP.ANALYSIS AS Analysis,COUNT(SP.ANALYSIS) AS Amount,
sum(case when SP.RESULT = 'POS' then 1 else 0 end) AS POS_Count
FROM SAMPLE S
INNER JOIN SAMPLE_PARTS SP ON SP.SAMPLEID = S.SAMPLEID
WHERE S.SAMPLE = '18000'
GROUP BY SP.ANALYSIS
PS: I'm using sum instead of count, but the effect is the same as it will add 1 for each POS and 0 for each value not equal to POS.
adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149