有两个sql语句
select count(tbxz) 投诉
from tsby where tbxz =0select count(tbxz) 表扬
from tsby where tbxz =1 怎么样把这两个结果集横向合并在一个表里面,形成如:投诉 表扬
12 15
select count(tbxz) 投诉
from tsby where tbxz =0select count(tbxz) 表扬
from tsby where tbxz =1 怎么样把这两个结果集横向合并在一个表里面,形成如:投诉 表扬
12 15
解决方案 »
- 收集网易数据库笔试题,欢迎大家拍砖
- 如何修改归档日志文件的保存路径?
- 谁有 rac stream 配置实例的详细文档
- 一个非常麻烦的问题,length('01')的长度是10这是为什么
- 'CREATE GLOBAL TEMPORARY TABLE的问题
- 急急急急!!!谁遇到到过ORA-00917 missing comma的错误!
- ORA-01652: 无法通过256(在表空间TEMP中)扩展 temp 段 如何解决??。。。。
- 这样的查询能实现吗?
- 如何让oracle8i速度更快?
- orcal update问题
- 请问在oracle中有没有ref和char类型之间相互转换的函数?!
- 急等啊,一个ORACLE的数据文件更新问题!!!!!!!!
from tsby where tbxz =0) a,(select count(tbxz) 表扬
from tsby where tbxz =1 ) b
select a.表扬,b.投诉 from (select count(tbxz) 表扬 from tsby where tbxz =0) a,
(select count(tbxz) 投诉 from tsby where tbxz =1 ) b
select sum(decode(tbxz,1,1,0)) "投诉", sum(decode(tbxz,0,1,0)) "表扬" from tsby
厉害;
decode的语法:
DECODE(value,if1,then1,if2,then2,if3,then3,...,else),表示如果value等于if1时,DECODE函数的结果返回then1,...,如果不等于任何一个if值,则返回else
select sum(decode(tbxz, '投诉', 1, 0)) "投诉",
sum(decode(tbxz, '表扬', 1, 0)) "表扬"
from tsby