February 25, 2026 at 4:34 pm
SELECT COUNT(DISTINCT Component) AS Found FROM tblComponents WHERE(Component NOT LIKE '%[a-z]%') AND(LTRIM(RTRIM(Component)) = 'GM13622') GROUP BY Component
How can I get the SELECT to return zero instead of null when there is no match?
February 25, 2026 at 5:08 pm
SELECT ISNULL(blah blah, 0) AS Found ...
February 25, 2026 at 5:17 pm
SELECT ISNULL(COUNT(DISTINCT Component), 0) AS Found FROM tblComponents WHERE(Component NOT LIKE '%[a-z]%') AND(LTRIM(RTRIM(Component)) = 'GM13622') GROUP BY Component
I still get NULL or am I not understanding what you are suggesting?
February 25, 2026 at 5:29 pm
Sorry. Try removing the GROUP BY
SELECT Found = COUNT(DISTINCT Component)
FROM tblComponents
WHERE (Component NOT LIKE '%[a-z]%')
AND (LTRIM(RTRIM(Component)) = 'GM13622');
February 25, 2026 at 5:53 pm
Thx! That worked.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply