Hi
Check this
SELECT DISTINCT COUNT([order]),count(Cus),name
FROM MEd inner join Portfolios on MEd .MEd ID = Port.MEd Ref
INNER JOIN Pro on Port.portID = Pro.portRef
INNER JOIN P on Pro.proID = P.proRef
WHERE Port.MEd = @ID
GROUP BY name
Best Regards
M.Mitwalli