SQL WHERE子句True或False值

时间:2014-03-18 22:38:06

标签: sql

我有一个表格,其中包含一个列,显示帐户是否处于无效状态。

列值为True或False ... I  只想要假物品。

所以我加入了一条条款: Where(account.inactive IN(“False”))

但是我的操作员/操作数类型不匹配?错误

我已经能够以这种方式做其他条款,但这个让我感到困惑。对不起,如果这是一个新手问题 - 感谢您的帮助。

以下是查询的副本。它的工作正常,除了where子句:

SELECT 
account.accountno, 
account.title AS AccountName,
account.sortcode,

CAST(ICASE(account.sortcode = "A",10,
account.sortcode = "B",11,
account.sortcode = "C",13,
account.sortcode = "D",12,
account.sortcode = "E",14,
account.sortcode = "F",15,
account.sortcode = "K",20,
account.sortcode = "M",20,
account.sortcode = "N",20,
account.sortcode = "P",21,
account.sortcode = "Q",22,
account.sortcode = "R",23,
account.sortcode = "S",24,
account.sortcode = "L",30,
account.sortcode = "U",30,
account.sortcode = "V",30,
account.sortcode = "X",30,
account.sortcode = "Z",32,
account.sortcode = "^",33,
account.sortcode = "W",31,
account.sortcode = "Y",34,0) AS NUMERIC) AS GLCatCode,

account.inactive,

system.company AS CompanyName 

FROM ((((account
LEFT JOIN trans
  ON account.uniqueid = trans.accountid AND account.ledgerno=1 AND trans.trantype NOT IN (8) )
LEFT JOIN period
  ON trans.periodno = period.periodno)
LEFT JOIN usercurr
  ON account.cncycode = usercurr.code)
LEFT JOIN system
  ON system.uniqueid = system.uniqueid)

Where (account.inactive IN ("False"))

GROUP BY 
account.accountno, 
AccountName, 
account.sortcode, 
account.inactive,
CompanyName, 
GLCatCode

ORDER BY 
account.sortcode ,  account.accountno 

4 个答案:

答案 0 :(得分:0)

你确定价值可能是'假'吗?检查可用于过滤的值:

SELECT DISTINCT account.inactive
FROM ((((account
LEFT JOIN trans
  ON account.uniqueid = trans.accountid AND account.ledgerno=1 AND trans.trantype NOT IN (8) )
LEFT JOIN period
  ON trans.periodno = period.periodno)
LEFT JOIN usercurr
  ON account.cncycode = usercurr.code)
LEFT JOIN system
  ON system.uniqueid = system.uniqueid)

答案 1 :(得分:0)

按如下方式更改WHERE子句?

Where (account.inactive = 'False')

答案 2 :(得分:0)

我查看了数据字典,它是一个字符长度的逻辑类型字段。我尝试了一些不同的东西和Where(account.inactive = 0),它似乎有效。

答案 3 :(得分:-1)

最好的办法是

Select /*+ your select creteria here, use decode() instead of CAST(ICASE) */

where condIsTrue = 'False'; --follow other things