以下代码在MySQL中测试通过,MSSQL应该能跑通,未测试。代码如下:#创建表如下
create temporary table tmp (a int, b int ,c int);
insert into tmp VALUES (1,10,1),(10,10,2),(10,100,2);
#mysql执行
select sum(case when c = "1" then A else B end) from tmp
#Oracle执行
select sum(decode(c,"1",a,b)) from tmp
#普通联合查询
select sum(d) from
(
select a as d from tmp where c=1
union
select b as d from tmp where c=2
) MySQL limit分页优化方法分享Oracle 11gR2 RAC安装时提示SWAP SIZE FAILED相关资讯 MySQL教程
- 30分钟带你快速入门MySQL教程 (02月03日)
- MySQL教程:关于I/O内存方面的一些 (01月24日)
- CentOS上开启MySQL远程访问权限 (01/29/2013 10:58:40)
| - MySQL教程:关于checkpoint机制 (01月24日)
- MySQL::Sandbox (04/14/2013 08:03:38)
- 生产环境MySQL 5.5.x单机多实例配 (11/02/2012 21:02:36)
|
本文评论 查看全部评论 (0)