I want to count the distinct cos.
This works just want to know if there is a way to put distinct and count together?
SELECT distinct m.cos, t.fo, Isnull(COUNT(m.cos), 0) AS penddds300
FROM t16pendmvt m JOIN t16pendall t ON m.cossn = t.cos
WHERE ( mvt_typ = 'R' ) AND (mvt_loc LIKE 'R%' or mvt_loc LIKE 'S%'
OR mvt_loc LIKE 'V%' ) and ( Datediff(DAY, t.conv_flg_cdt, Getdate()) > 300 )
GROUP BY t.fo, m.cos
order by t.fo
This works just want to know if there is a way to put distinct and count together?
SELECT distinct m.cos, t.fo, Isnull(COUNT(m.cos), 0) AS penddds300
FROM t16pendmvt m JOIN t16pendall t ON m.cossn = t.cos
WHERE ( mvt_typ = 'R' ) AND (mvt_loc LIKE 'R%' or mvt_loc LIKE 'S%'
OR mvt_loc LIKE 'V%' ) and ( Datediff(DAY, t.conv_flg_cdt, Getdate()) > 300 )
GROUP BY t.fo, m.cos
order by t.fo