Problem with a WHERE statement
-
I am trying to run this query; declare @StartDate DateTime declare @EndDate DateTime set @StartDate = cast('2007/10/22' as DateTime) set @EndDate = cast('2007/11/05' as DateTime) SELECT RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text, COUNT(RT_MCP_Alarm_Text) AS Error_Count, CONVERT(char(10), RT_MCP_Date_Time, 111) as ErrorDate, RT_MCP_Bit_State as BOOLEAN FROM RT_MCP_Historic_Alarms where RT_MCP_Date_Time >@StartDate and RT_MCP_Date_Time RT_MCP_Bit_State <> FALSE GROUP BY RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text, CONVERT(char(10), RT_MCP_Date_Time, 111) ORDER BY RT_MCP_Date_Time, Error_Count DESC, RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text I recieve this error when I try to run it. The BOLDED column is a BIT type, for a True/False choice. I do not need to know when the items go false, only when the meet the TRUE bit. Thanks,
-
I am trying to run this query; declare @StartDate DateTime declare @EndDate DateTime set @StartDate = cast('2007/10/22' as DateTime) set @EndDate = cast('2007/11/05' as DateTime) SELECT RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text, COUNT(RT_MCP_Alarm_Text) AS Error_Count, CONVERT(char(10), RT_MCP_Date_Time, 111) as ErrorDate, RT_MCP_Bit_State as BOOLEAN FROM RT_MCP_Historic_Alarms where RT_MCP_Date_Time >@StartDate and RT_MCP_Date_Time RT_MCP_Bit_State <> FALSE GROUP BY RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text, CONVERT(char(10), RT_MCP_Date_Time, 111) ORDER BY RT_MCP_Date_Time, Error_Count DESC, RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text I recieve this error when I try to run it. The BOLDED column is a BIT type, for a True/False choice. I do not need to know when the items go false, only when the meet the TRUE bit. Thanks,
Use 0 and 1 to test a BIT value
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Use 0 and 1 to test a BIT value
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Figured this out after I wrote it. The other problem I had was; ORDER BY RT_MCP_Date_Time, Error_Count DESC, RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text I declared the RT_MCP_Date_Time as ErrorDate in the select statement and didn't put it in the ORDER BY statement correctly. Thanks for your help.