ORACLE 语句关联统计
很久不用SQL语句了,貌似入职新公司后,又回归到了三年前的SQL时代,一写一坨的SQL好吧,也当回归一下过去的知识。
下面是统计2月份某数据的计费统计
select t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间,
(case state when 0
then '0 正常' end)计费状态 from t_unreg_log t where t.bill_start_date<to_date('20150301','yyyymmdd') and t.bill_start_date>to_date('20150201','yyyymmdd')
and t.unreg_time<to_date('20150301','yyyymmdd') and t.unreg_time>to_date('20150201','yyyymmdd')
and t.type='9' union
select t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间,
(case state when 0
then '0 正常' end)计费状态 from t_unreg_log t where t.bill_start_date<to_date('20150301','yyyymmdd') and t.bill_start_date>to_date('20150201','yyyymmdd')
and t.unreg_time>to_date('20150301','yyyymmdd')
union select t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间,
(case state when 0
then '0 正常' end)计费状态 from t_unreg_log t where t.bill_start_date is not null
and t.bill_start_date<to_date('20150201','yyyymmdd') and t.unreg_time<to_date('20150301','yyyymmdd') and t.unreg_time>to_date('20150201','yyyymmdd')
and t.type='9'
union
select t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间,
(case state when 0
then '0 正常' end)计费状态 from t_online_info t where t.bill_start_date is not null and t.bill_start_date<to_date('20150301','yyyymmdd'))
写完之后发现这么多的冗余代码。
ORACLE 语句关联统计的更多相关文章
- 53个Oracle语句优化规则详解(转)
Oracle sql 性能优化调整 1. 选用适合的ORACLE优化器 ORACLE的优化器共有3种:a. RULE (基于规则) b. COST (基于成本) c. CHOOSE ...
- oracle里的统计信息
1 oracle里的统计信息 Oracle的统计信息是这样的一组数据,存储在数据字典,从多个维度描述了oracle数据库对象的详细信息,有6种类型 表的统计信息:记录数.表块的数量.平均行长度等 索引 ...
- 关于Oracle开启自动收集统计信息的SPA测试
主题:关于Oracle开启自动收集统计信息的SPA测试 环境:Oracle RAC 11.2.0.4(Primary + Standby) 需求:生产Primary库由于历史原因关闭了自动统计信息的收 ...
- Oracle 语句中“||”代表什么啊?
Oracle 语句中“||”代表什么啊? Oracle 语句中“||”代表什么啊?跟ServerSQL中的字符串的连接符“+”是一个概念么? 1. 恩是的 是一个含义...select '1'||'2 ...
- 基于Oracle的SQL优化(崔华著)-整理笔记-第5章“Oracle里的统计信息”
第5章“Oracle里的统计信息” 详细介绍了Oracle数据库里与统计信息相关的各个方面的内容,包括 Oracle数据库中各种统计信息的分类.含义.收集和查看方法,以及如何在Oracle数据库里正确 ...
- 学习ThinkPHP的第21天---关联预载入、关联统计
ThinkPHP关联预载入 预载入的作用是减少执行SQL语句,进而提升程序的性能. public function join(){ //用于监听SQL Db::listen(function ($sq ...
- MyBatis项目实战 快速将MySQL转换成Oracle语句
一.前言 因项目需求,小编要将项目从mysql迁移到oracle中 ~ 之前已经完成 数据迁移 (https://zhengqing.blog.csdn.net/article/details/103 ...
- [转载]T-SQL(Oracle)语句查询执行顺序
原文链接:http://blog.sina.com.cn/s/blog_61c006ea0100mlgq.html sql语法的分析是从右到左,where子句中的条件书写顺序,基本上对sql性能没有影 ...
- 性能测试常用Oracle语句
性能测试常用Oracle语句 显示数据库当前的连接数 select count(*) from v$process; 显示数据库最大连接数: select value from v$parameter ...
随机推荐
- C++-copy constructor、copy-assignment operator、destructor
本文由@呆代待殆原创,转载请注明出处. 对于一个类来说,我们把copy constructor.copy-assignment operator.move constructor.move-assig ...
- Parallel.ForEach() 并行循环
现在的电脑几乎都是多核的,但在软件中并还没有跟上这个节奏,大多数软件还是采用传统的方式,并没有很好的发挥多核的优势. 微软的并行运算平台(Microsoft’s Parallel Computing ...
- Oracle安装步骤及PL/SQL Developer连接数据库
一:Oracle安装步骤及PL/SQL Developer连接数据库 win7 64位 11g 点击(操作步骤):http://www.cnblogs.com/haoke/articles/27343 ...
- 怒刷DP之 HDU 1257
最少拦截系统 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- Java操作XML的工具类
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.Inp ...
- sysobjects.xtype介绍
SQL Server数据库的一切信息都保存在它的系统表格里. 在大多数情况下,对你最有用的两个列是Sysobjects.name和Sysobjects.xtype.前面一个用来列出待考察对象的名字,而 ...
- curl模拟浏览器进行phpQuery抓取数据
报Warning: file_get_contents(http://www.dianping.com/shop/8042874) [function.file-get-contents]: fail ...
- 根据不同的分辨率选择不同的css文件
<SCRIPT language=javascript> <!-- Begin if (screen.width == 640) { document.write('<link ...
- Intent.ACTION_PICK
在常见的Activity Action Intent常量中,ACTION_PICK android.intent.action.PICK 是“选择数据”的意思,来简单的分享一下我知道的Intent. ...
- (转)Android面试题
1. 下列哪些语句关于内存回收的说明是正确的? (b ) A. 程序员必须创建一个线程来释放内存 B.内存回收程序负责释放无用内存 C.内存回收程序允许程序员直接释放内存 D.内存回收程序可以在 ...