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 ...
随机推荐
- Is an MTD device a block device or a char device?
转:http://www.linux-mtd.infradead.org/faq/general.html#L_mtd_what Note, you can find Ukranian transla ...
- VirtualBox 导入.vdi文件时报“uuid is exists”错误
解决办法: 1.要安装的.vdi文件所在目录:D:\developTools\vm\RedHatLinux1.vdi 2.找到VirtualBox的安装目录,这里是D:\Program Files\O ...
- ScrollView嵌套ListView的滑动冲突问题,是看大神的方法的,作为学习以后用的到
在工作中,曾多次碰到ScrollView嵌套ListView的问题,网上的解决方法有很多种,但是杂而不全.我试过很多种方法,它们各有利弊. 在这里我将会从使用ScrollView嵌套ListView结 ...
- iOS tabbar 控制器基本使用
RootViewController *rootVC=[[RootViewController alloc] init] SignInViewController *signVC = [[SignIn ...
- NSTimer定时器的用法
#import "ViewController.h" @interface ViewController () { NSTimer *countDownTimer; int cou ...
- Flask-在浏览器中直接显示文本文件中的内容
目录结构: project├── info.json├── run.py└── static └── readme.txt # 直接返回static目录下的文件内容 @app.route( ...
- What are definitions of Model, Inference and Algorithm and its associations ?
1.拿初中的二元一次方程来说明: 1.1)说model就好比一元二次方程,它是个方程模型: 1.2)再说inference是求解该方程的某种方法--加减消元法(重在推理): 1.3)最后说algori ...
- 解决eclipse配置Tomcat时找不到server选项
集成Eclipse和Tomcat时找不到server选项: 按照网上的步骤如下: 在Eclipse中,窗口(window)——首选项(preferences)——服务器(Server)——运行时环境( ...
- Linux后台运行
关于linux后台 ctrl + z jobs -l fg %jobnumber 后台调前台 bg %jobnumber 后台暂停--后台运行 kill pid ps -aux | grep &quo ...
- GSS6 4487. Can you answer these queries VI splay
GSS6 Can you answer these queries VI 给出一个数列,有以下四种操作: I x y: 在位置x插入y.D x : 删除位置x上的元素.R x y: 把位置x用y取替 ...