Boolean Logic in Select Statement
sql, sql-server-2008
Solution
SELECT t.[Key]
,t.[Parent_Key]
,t.[Parent_Code]
,t.[Code]
,t.[Desc]
,t.[Point]
,CASE WHEN t.[Point] > 2 THEN 1 ELSE
CASE WHEN t.[Point] = 1 THEN 0 ELSE NULL END
END AS [isChild]
,t.[By]
,t.[On]
FROM [db].[stats] t WHERE t.[Parent_Key]= @tmpParameter
Be aware that when t.[Point] < 1 then [isChild] will be null
Problem
How do I implement boolean logic in the select statement while the query is running? ``` SELECT t.[Key] ,t.[Parent_Key] ,t.[Parent_Code] ,t.[Code] ,t.[Desc] ,t.[Point] ,[isChild] -- If Point > 2, then true, if Point == 1 Then false ,t.[By] ,t.[On] FROM [db].[stats] t WHERE t.[Parent_Key]= @tmpParameter ``` I want make some logic to determine [isChild] boolean value based on t.[Point]