Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problem with a WHERE statement

Problem with a WHERE statement

Scheduled Pinned Locked Moved Database
helpdatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    solutionsville
    wrote on last edited by
    #1

    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,

    C 1 Reply Last reply
    0
    • S solutionsville

      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,

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      S 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        S Offline
        S Offline
        solutionsville
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups