oracle 语句理解 (-)
2015-09-24 13:58
691 查看
select COALESCE(total.fab, preborrow.fab,'-') fab,nvl(total.qty,0) total,nvl(borrow.qty,0) borrow,nvl(idle.qty,0) idle,nvl(overdue.qty,0)
overdue,nvl(preborrow.qty,0) preborrow from(select fab,count(*) qty from mpb_camera_r where fab is not null and is_active='Y' and camera_type=Camera group by fab ) total
left join (select fab,count(*) qty from mpb_camera_r where fab is not null and is_active='Y' and camera_type=Camera and status='Using' group by fab) borrow on total.fab=borrow.fab left join (select fab,count(*) qty from mpb_camera_r where fab is not null and
is_active='Y' and camera_type=Camera and status='Idle' group by fab) idle on total.fab=idle.fab
left join (select fab,count(*) qty from mpb_camera_r where fab is not null and is_active='Y' and camera_type=Camera and status='Using' and sysdate > status_update_time+ " + alertTime.ToString() + " /24 group by fab) overdue
on total.fab=overdue.fab " +
"full join (select fab,count(*) qty from mpb_preborrow_r where fab is not null and status='PRE' and equipment_type=Camera group by fab) preborrow on total.fab=preborrow.fab ";
1:select字句的《目标列表达式》 不仅可以是表中的属性列也可也是表达式
如: select 2015—age from student 得到学生出生年份
用户可以指定别名来改变查询结果的列标题 这对于含算术表达式,常量,函数名的目标列表达式尤为重要
select sname Name,'Year of Birth' Brith,2015-age Brithday,Lower(sdept) Department from student;
2:函数COALESCE :
3:nvl:
4:left join
5:full join
6:count(*)
overdue,nvl(preborrow.qty,0) preborrow from(select fab,count(*) qty from mpb_camera_r where fab is not null and is_active='Y' and camera_type=Camera group by fab ) total
left join (select fab,count(*) qty from mpb_camera_r where fab is not null and is_active='Y' and camera_type=Camera and status='Using' group by fab) borrow on total.fab=borrow.fab left join (select fab,count(*) qty from mpb_camera_r where fab is not null and
is_active='Y' and camera_type=Camera and status='Idle' group by fab) idle on total.fab=idle.fab
left join (select fab,count(*) qty from mpb_camera_r where fab is not null and is_active='Y' and camera_type=Camera and status='Using' and sysdate > status_update_time+ " + alertTime.ToString() + " /24 group by fab) overdue
on total.fab=overdue.fab " +
"full join (select fab,count(*) qty from mpb_preborrow_r where fab is not null and status='PRE' and equipment_type=Camera group by fab) preborrow on total.fab=preborrow.fab ";
1:select字句的《目标列表达式》 不仅可以是表中的属性列也可也是表达式
如: select 2015—age from student 得到学生出生年份
用户可以指定别名来改变查询结果的列标题 这对于含算术表达式,常量,函数名的目标列表达式尤为重要
select sname Name,'Year of Birth' Brith,2015-age Brithday,Lower(sdept) Department from student;
2:函数COALESCE :
3:nvl:
4:left join
5:full join
6:count(*)
相关文章推荐
- oracle 统计信息
- Oracle 中count函数用法
- Oracle EBS Model Function Technical
- oracle sql 日期yyyy-MM-dd字符串和timstamp类型相互转换
- oracle 函数
- centos下为php开oracle扩展
- Linux Red Hat 5.6下安装Oracle 11gR2(最新版原创)
- oracle之check约束小结
- oracle学习笔记(聚合函数以及group by 和having 的用法)
- pl/sql 导出oracle表结构
- Driver class 'oracle.jdbc.driver.OracleDriver' could not be found
- Oracle中表被删除或数据被错误修改后的恢复方法
- oracle : olumn to be modified must be empty to decrease precision or scale
- [oracle学习笔记]之一:sql/plus基础操作
- RMAN备份 CATALOG
- oracle rac12c dbca创建集群实例时候,只能识别到一个节点
- 来,复习一哈Oracle事务的ACID特性
- Dave-oracle
- oracle 11g oem的建立方法
- Oracle分页查询格式(九)