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. Pandas DataFrame数据的增、删、改、查

    Pandas DataFrame数据的增.删.改.查 https://blog.csdn.net/zhangchuang601/article/details/79583551 #删除列 df_2 = ...

  2. CSS之:active选择器

    Active的一段话 active的英文解释为“积极的”,表现在鼠标上就是点击的意思.关于active选择器最多的示例恐怕就是应用在链接上面的,然而打开链接是一个一瞬间的动作,这不能很好的体现acti ...

  3. laravel 批量更新

    /** * 转发动态和资讯数量统计 */ public function forwardCounts(FeedModel $feedModel) { //统计动态转发的id $feeds=$feedM ...

  4. SqlServer中查看索引的使用情况

    --查看数据库索引的使用情况 select db_name(database_id) as N'TOPK_TO_DEV', --库名 object_name(a.object_id) as N'Top ...

  5. NodeJS学习:环境变量

    简介 环境变量(environment variables) 不属于 NodeJS 范畴,它是操作系统用于设定执行环境的参数.会在程序运行时传递给应用程序. NodeJS 获取环境变量,是通过 glo ...

  6. android studio 3.0之后版本自定义文件名生成apk文件

    修改app模块的build.gradle 在android闭包中添加以下代码 //指定打包后应用名称 android.applicationVariants.all { variant -> v ...

  7. 【LOJ】#6432. 「PKUSC2018」真实排名

    题解 简单分析一下,如果这个选手成绩是0,直接输出\(\binom{n}{k}\) 如果这个选手的成绩没有被翻倍,那么找到大于等于它的数(除了它自己)有a个,翻倍后不大于它的数有b个,那么就从这\(a ...

  8. Wireshark、Netcat

    Wireshark Wireshark是一个网络数据包分析软件,功能是截取网络数据包,并尽可能显示出最为详细的网络数据包数据.为了安全考虑,wireshark只能查看封包,而不能修改封包的内容,或者发 ...

  9. MySQL Binlog 介绍

    Binlog 简介 MySQL中一般有以下几种日志: 日志类型 写入日志的信息 错误日志 记录在启动,运行或停止mysqld时遇到的问题 通用查询日志 记录建立的客户端连接和执行的语句 二进制日志 记 ...

  10. 暴力探测蓝牙设备工具redfang

    暴力探测蓝牙设备工具redfang   根据是否可以被扫描到,蓝牙设备具有可见(Disoverable)和不可见(non discoverable)两种模式.为了扫描不可见蓝牙设备,Kali Linu ...