很久不用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 0then '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' unionselect   t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间, (case state  when 0then '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')unionselect t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间, (case state  when 0then '0 正常'  end)计费状态  from t_unreg_log t where t.bill_start_date is not nulland 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'unionselect t.telno as 主号,VID 副号,t.area_code 地区, t.reg_time 注册时间,t.reg_source 注册工号,t.bill_start_date 计费时间, (case state  when 0then '0 正常'  end)计费状态   from t_online_info t where t.bill_start_date is not null and t.bill_start_date<to_date('20150301','yyyymmdd'))

写完之后发现这么多的冗余代码。

转载于:https://www.cnblogs.com/dashouqianxiaoshou/p/4543458.html

ORACLE 语句关联统计相关推荐

  1. oracle分组关联统计,没有记录则显示0

    数据如下 A表 atab id name 1 张三 2 李四 3 王五 – B表 btab a_id score 1 8 1 6 1 10 2 10 2 10 2 3 结果展示 统计他们得过几次10分 ...

  2. oracle stalestats_深入理解oracle优化器统计数据(Optimizer Statistics)

    理解oracle优化器统计数据 首先来介绍oracle数据库使用基于规则优化器(RBO)来决定如何执行一个sql语句.基于规则优化器顾名思义,它是遵循一组规则来判断一个sql语句的执行计划.这组规则是 ...

  3. Oracle 语句大全,确实不错,赶紧转走!

    1. Oracle安装完成后的初始口令?  internal/oracle  sys/change_on_install  system/manager  scott/tiger  sysman/oe ...

  4. Oracle语句函数

    目录 oracle语句 ddl语句 create 建表 create 备份表 改列名 改列的字段类型 增加列 删除列 为字段添加注释 dml语句 插入 修改 删除 复制表数据 insert into ...

  5. Oracle多列统计信息

    Oracle多列统计信息 通常,当我们将SQL语句提交给Oracle数据库时,Oracle会选择一种最优方式来执行,这是通过查询优化器Query Optimizer来实现的.CBO(Cost-Base ...

  6. Oracle 语句大全

    1. Oracle安装完成后的初始口令? internal/oracle sys/change_on_install system/manager scott/tiger sysman/oem_tem ...

  7. oracle 语句提高查询效率的方法

    oracle 语句提高查询效率的方法 1:.. where column in(select * from ... where ...); 2:... where exists (select 'X' ...

  8. oracle关联分组查询,oracle中关联查询、分组查询

    高级查询 1.关联查询 作用:可以跨越多表查询 --查询出员工的名字和他所在部门的的名字 //古老的写法 select first_name,name from s_emp,s_dept where ...

  9. 资源放送丨《Oracle 12C~19C统计信息的最佳实践》PPT视频

    前段时间,墨天轮邀请到云和恩墨解决方案专家 黄廷忠 分享了直播<Oracle 12C~19C统计信息的最佳实践>,在这里我们共享一下PPT和视频,供大家参考学习. 优化器是Oracle数据 ...

最新文章

  1. Linux磁盘怎么备份,Linux的硬盘分区表备份与还原
  2. CSS篇 《图解CSS3》笔记 Flex
  3. 嵌入式系统低功耗管理(备忘)
  4. objective c 语法
  5. 这三个Offer,你怎么选?
  6. 研讨会 | 知识工程与问答技术研讨会 (KEQA2018)
  7. 拆解百度自动驾驶最新动作:Apollo企业版和Apollo 3.5里的生意经和新风向 | CES 2019...
  8. linux composer使用php,记录linux下composer使用的坑爹过程
  9. JS浏览器对象-Location对象
  10. Win10 台式机机箱前置耳机插孔没声音如何修复
  11. 10个WEB设计戒律 和 10个设计师戒律
  12. 396万奖金池!视觉特征编码、AI+无线通信两大赛道等你来战!助力元宇宙!
  13. 大学英语综合教程二 Unit 8 课文内容英译中 中英翻译
  14. php的本地地址,php获取本机ip或远道地址
  15. C语言>>8 0xFF; 0xFF;作用
  16. 关于naked (C++)
  17. 上海工程技术大学计算机专硕,上海工程技术大学2019年硕士研究生调剂公告
  18. Lucas定理与扩展Lucas
  19. 设备巡检、点检记录解决方案
  20. 电气器件系列三十五:开关电源选型实例

热门文章

  1. C语言操作符详解 隐式类型转换 (整型提升 算数转换)
  2. python用pandas读取excel_使用Pandas或其他模块在Python中读取没有隐藏列的Excel文件...
  3. java hibernate 包_java – Hibernate映射包
  4. linux脚本怎么获取参数,在Bash shell脚本编程中,如何正确无误获取到“脚本选项参数”和“脚本参数”呢?...
  5. delphi与java_Delphi XE8中Delphi和JAVA数据类型对应关系!
  6. centos8 ssh配置_JumpServer 堡垒机CentOS 8 安装部署(四)
  7. python离散化方法_python中字符串离散化的例子
  8. C语言排序方法------快速排序
  9. Linux下docker的安装及常用命令
  10. NYOJ-非洲小孩(贪心)