Is there a faster alternative to check if a SELECT statement is null in CASE statements in SQL server?

StackOverflow https://stackoverflow.com/questions/22810320

문제

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!

도움이 되었습니까?

해결책

Faster to type...

isnull(statement, 0)

다른 팁

WITH cte
AS
(
    SELECT co11
    FROM ...
)
SELECT ISNULL(cte.col1, 0) as [Variable Name]
FROM cte
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top