SQL Puzzle: Find rows with more NULL values in Columns

Question: Find the rows that have more than one NULL value across its columns. check below the sample data and expected output.

Input Data:



Expected Output:




Data Script:



CREATE Table Puzzle2
(
	ID NVARCHAR(15),
	Col1 NVARCHAR(15) NULL,
	Col2 NVARCHAR(15) NULL,
	Col3 NVARCHAR(15) NULL
)

INSERT INTO Puzzle2 VALUES
	(1,'a',NULL,'b'),
	(2,NULL,'b','c'),
	(3,NULL,NULL,NULL),
	(NULL,'1',NULL,'0'),
	(5,'X',NULL,NULL)

SELECT * FROM Puzzle2


Please try to answer the question, if you still not able to get it click below show button to see the answer.

No comments:

Post a Comment