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. C# 解决VS2008在win7找不到输入序列号的地方

    1.VS2008在Windows7 打开维护界面看不到可以输序列号的地方. 因为微软把他隐藏了. 2.我们可以借用工具把他显示出来 下载地址:http://www.zlsoft.com/techbbs ...

  2. spm

    Spatial Pyramid Matching 看了很多关于SPM的介绍,但是网络上的资源大多都是对论文Beyond bags of features: Spatial pyramid matchi ...

  3. 关于v4包的Fragment过渡动画的事件监听无响应问题解决

    项目中部分功能模块采用了单Activity+多Fragment模式,当Fragment切换时,需要在过渡动画执行完后做一些操作,通常就是在自己封装的FragmentBase中重写onCreateAni ...

  4. L0,L1,L2范数,正则化,过拟合

    L0范数是指向量中非0元素的个数 L1范数是向量中各个元素的绝对值求和 L2范数是指向量的各个元素平方求和然后取和的平方根 机器学习的目的是使学习到的模型不仅对已知的数据而且对未知的数据有很好的预测能 ...

  5. linux系统基本排查

    1.查看内存使用情况 free -g 当观察到free栏已为0的时候,表示内存基本被吃完了,那就释放内存吧. 释放内存: sync echo 3 > /proc/sys/vm/drop_cach ...

  6. BAT获取FTP指定文件

    以下两个文件放在同一目录下 getfile.bat文件内容如下: @echo offftp.exe -i -s:getfile.txt 192.168.1.2(更换成你的ip,参数之间有空格)paus ...

  7. retrying模块的学习

    retrying模块的学习 我们在写爬虫的过程中,经常遇到爬取失败的情况,这个时候我们一般会通过try块去进行重试,但是每次都写那么一堆try块,真的是太麻烦,所以今天就来说一个比较pythonic的 ...

  8. .NET下获取应用程序目录的一些方法

    今天在Console Application下搞了一个小功能,期间需要获取当前应用程序的根目录,试了很多方式,都不能直接获取到,没有像Server.MapPath()这类的方法来方便地使用. 下面列举 ...

  9. Zookeeper命令行zkCli.sh&zkServer.sh的使用(四)

    上篇博文,我们成功的安装和启动了zookeeper服务器,zookeeper还提供了很多方便的功能,方便我们查看服务器的状态,增加,修改,删除数据(入口是zkServer.sh和zkCli.sh).还 ...

  10. 跟据经纬度实现附近搜索Java实现

    现在很多手机软件都用附近搜索功能,但具体是怎么实现的呢>在网上查了很多资料,mysql空间数据库.矩形算法.geohash我都用过了,当数据上了百万之后mysql空间数据库方法是最强最精确的(查 ...