Question

Is there a faster version for this case statement?

CASE
 WHEN (SELECT STATEMENT) IS NOT NULL
 THEN (SELECT STATEMENT)
 ELSE 0
END AS [Variable Name]

Where the SELECT STATEMENTdoesn't change from line 2 to line 3.

Thank you!

Was it helpful?

Solution

Faster to type...

isnull(statement, 0)

OTHER TIPS

WITH cte
AS
(
    SELECT co11
    FROM ...
)
SELECT ISNULL(cte.col1, 0) as [Variable Name]
FROM cte
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top