SQL应用报错800.Corresponding types must be compatible in CASE expression.

错误描述:

11:00:51  [SELECT - 0 row(s), 0.000 secs]  [Error Code: -800, SQL State: IX000]  Corresponding types must be compatible in CASE expression.

... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec  [0 successful, 0 warnings, 1 errors]

IBM解释:  

Cause

The data types of the THEN and ELSE part are different. For example the THEN part return a date value and the ELSE part return a date/time value.

Environment

Windows

Diagnosing the problem

Check your report for IF/THEN/ELSE expressions.

Resolving the problem

Verify your Impromptu report for IF/THEN/ELSE expressions. 
Check the data type of the THEN part with the data type of the ELSE part. Both need to be return the same data type. If not you need to add an additional calculation or a function to transform the result into a result with the required data type.

Exapmle:

IF ( column <> 1 ) THEN ( date ) ELSE ( date + 001 00:00:00:000 )

The THEN part returns a date value (data type: date)
The ELSE part returns a date/time value (data type: date/time)

Modify the above expression into:

IF ( column <> 1 ) THEN ( date + 000 00:00:00:000 ) ELSE ( date + 001 00:00:00:000 )

The THEN part returns a date/time value.
The ELSE part returns a date/time value.

or 
IF ( column <> 1 ) THEN ( date ) ELSE ( datetime-to-date ( date + 001 00:00:00:000 ) )

The THEN part returns a date value.
The ELSE part returns a date value.

参见:

http://www-01.ibm.com/support/docview.wss?uid=swg21425745

举例分析:

select  unique case when month(statdate) <10 then 0||month(statdate) else ''||month(statdate) end  statdate from  disxxx
where statdate = '20130731' or statdate = '20121231';
select  unique case when month(statdate) <10 then 0||month(statdate) else month(statdate) end  statdate from  disxxx
where statdate = '20130731' or statdate = '20121231'

0||month(statdate)  这个得到的 是一个字符串
month(statdate) 这个得到的是个 数字。

两个冲突!

[SQL ERROR 800]Corresponding types must be compatible in CASE expression.的更多相关文章

  1. IBM DB2 SQL error code list

    SQL return codes that are preceded by a minus sign (-) indicate that the SQL statement execution was ...

  2. Slave SQL: Error 'Incorrect string value ... Error_code: 1366

    背景: 主从环境一样,字符集是utf8. Slave复制报错,平时复制都正常也没有出现过问题,今天突然报错: :: :: :: :: Error_code: :: perror 1366 MySQL ...

  3. SQL Error (1130): Host '192.168.1.126' is not allowed to connect to this MySQL server

    通过HeidiSQL连接MYSQL数据库报错: SQL Error (1130): Host '192.168.1.126' is not allowed to connect to this MyS ...

  4. 通过navicat连接mysql服务器提示SQL Error (1130): Host '192.168.1.100' is not allowed to connect to this MySQL server

    新装一个mysql,尝试用通过navicat连接mysql服务器的时候提示: SQL Error (1130): Host '192.168.1.100' is not allowed to conn ...

  5. Sqlite出现SQL error: database disk image is malformed的处理

    SQLite有一个很严重的缺点就是不提供Repair命令.导致死亡提示database disk image is malformed它的产生有很多种可能,比如,磁盘空间不足,还有就是写入数据过程中突 ...

  6. DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, SQLERRMC=2 (转载)

    http://blog.csdn.net/xiyuan1999/article/details/5706230 DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, ...

  7. Mysql远程连接报错:SQL Error (1130): Host '192.168.61.128' is not allowed to connect to this MySQL server

    Mysql远程连接报错:SQL Error (1130): Host '192.168.0.18' is not allowed to connect to this MySQL server     ...

  8. Oracle Alert - APP-ALR-04108: SQL error ORA-01455

    SELECT OD.ORGANIZATION_CODE, TO_CHAR(H.ORDER_NUMBER), --ORACLE ALERT 自动转数字类型最长11位,转字符处理解决APP-ALR-041 ...

  9. Mysql远程连接报错:SQL Error (1130): Host '192.168.6.128' is not allowed to connect to this MySQL server

    通过SQLyog连接linux中的MySQL报错问题:SQL Error (1130): Host '192.168.6.128' is not allowed to connect to this ...

随机推荐

  1. 【译】SQLskills SQL101:Trace Flags、ERRORLOG、Update Statistics

    最近阅读SQLskills SQL101,将Erin Stellato部分稍作整理.仅提取自己感兴趣的知识点,详细内容请阅读原文. 一.Trace Flags推荐开启三个跟踪标记1118.3023.3 ...

  2. Struts2不扫描jar包中的action

    今天在做一个二开的项目,将struts打成jar包放在WEB-INF的目录下却扫描不到指定的路径,也就是http访问访问不到我们指定的action,其他代码可以正常使用,就是访问不到action.st ...

  3. 转载:Linux批量远程管理主机命令_pssh用法详解

    原文:http://www.linuxidc.com/Linux/2011-12/49635p2.htm (一) 使用前提 中心主机连接远程主机可以通过ssh密钥无密码连接 (二) 命令格式 pssh ...

  4. VS2017插件开发-项目右键菜单

    1.创建自定义命令 2.更改.vsct中Group节点的id <Group guid="guidPublishOwinPackageCmdSet1" id="MyM ...

  5. 不使用第三方软件、使用IE11自带功能来屏蔽浏览器广告

    第一步: 下载后面的附件http://files.cnblogs.com/limits/IE11%E5%8E%BB%E5%B9%BF%E5%91%8A.zip 打开此路径IE11跟踪保护+CSS去广告 ...

  6. 001_Eclipse编写第一个Java程序

    1 下载并安装jdk 2 下载较新版本的eclipse,eclipse都是非安装版的,解压缩即可. 3 双击eclipse.exe,打开elipse软件 4 FileàNewàProject 5 选择 ...

  7. NET Core中使用Angular2的Token base身份认证

    下载本文提到的完整代码示例请访问:How to authorization Angular 2 app with asp.net core web api 在ASP.NET Core中使用Angula ...

  8. Eclipse 之开发环境的常用配置

    一.Java智能提示 (1). 打开Eclipse,选择打开" Window - Preferences". (2). 在目录树上选择"Java-Editor-Conte ...

  9. php 会话控制(了解cookie与session之间的区别与联系)

    相同点: 都可以在解决HTTP无状态的问题,使同一个客户端在访问网站的多次请求中,可以保存,设置信息,并且在请求事物之间建立联系. 不同点: 简单的说cookie的信息保存在客户端,session的信 ...

  10. Vue之双向绑定原理动手记

    Vue.js的核心功能有两个:一是响应式的数据绑定系统,二是组件系统.本文是通过学习他人的文章,从而理解了双向绑定原理,从而在自己理解的基础上,自己动手实现数据的双向绑定. 目前几种主流的mvc(vm ...