Wednesday, February 24, 2010

COALESCE function

Do you remember COALESCE function?
What would be the output of the following scripts?
CREATE TABLE #Test(a INT NULL, b INT NULL, c INT NULL)
INSERT INTO #Test(a,b,c) VALUES(1,1,NULL)
INSERT INTO #Test(a,b,c) VALUES(NULL,2,NULL)
INSERT INTO #Test(a,b,c) VALUES(1,NULL,3)
SELECT COALESCE(a,b,c) FROM #Test

A. 1,2,3
B. 1,NULL,1
C. 1,2,1
D. NULL,NULL,NULL
E. NULL,2,3
F. 1,NULL,3

Answer:[C]
Highlight to find out the answer.

No comments:

Post a Comment

Oracle Query