oracle 基本函数小例子--查询身高段分数段
select * from student order by id
drop table student
select * from oracletest
create table student(
idcard varchar2(18),
name varchar2(20),
sex int,
high int,
age int
)
insert into student values ('450326198912241844','罗江超',0,178,null);
insert into student values('411424198912068072','候桂申',0,158,null);
insert into student values('450881199006112350','潘海林',0,177,null);
insert into student values('450111197806062156','韦山',0,175,null);
insert into student values('450103197912150539','廖韵',0,173,null);
insert into student values('450324198809231637','唐文林',0,178,null);
insert into student values('450111197806061234','小明',0,180,null);
commit
select * from student
--年龄最大的人
select * from student where substr(idcard,7,8)=(select min(substr(idcard,7,8)) as birt from student)

select * from student where
截取字符串substr
substr(idcard,7,8) in ('19891224','19780606')

select * from student where idcard like '%19780606%'

以......排序
select rownum,substr(idcard,7,8) as birt,s.*
from student s order by birt asc

-------------------------
select rownum,t.* from (
select substr(idcard,7,8) as birt,s.*
from student s order by birt asc
) t
where rownum=1
union
select rownum,t.* from (
select substr(idcard,7,8) as birt,s.*
from student s order by birt desc
) t
where rownum=1

------------------------
select * from student s for update
commit
delete from student
truncate table student
select
sex 性别,
count(1) 总人数,
min(high) 最矮,
max(high) 最高,
avg(high) 平均
from student s group by sex

这个0是什么呢这时就需要decode函数
别名decode
select
decode(sex,0,'男',1,'女',2,'人妖') 性别,
count(1) 总人数,
min(high) 最矮,
max(high) 最高,
avg(high) 平均
from student s group by sex

select
high,
count(1) 总人数
from student s group by high

--1.5米段,1.6米段,1.7米段,1.8米段 人数
select * from (
select 身高段,count(1) 人数 from
(
select
case
when high>=150 and high<160 then '1.5米段'
when high>=160 and high<170 then '1.6米段'
when high>=170 and high<180 then '1.7米段'
when high>=180 then '1.8米段'
end 身高段
from student s
) tt
group by 身高段
)
pivot(count(人数) for 身高段 in ('1.5米段','1.6米段','1.7米段','1.8米段'));

oracle 基本函数小例子--查询身高段分数段的更多相关文章
- vb.net写的odbc连接dsn数据源和ole链接oracle的小例子
最近由于工作需要开始接触vb2010,也叫vb.net.相比vb6.0有面向对象编程的优势.同时接触一门新语言,要更快的实际应用起来,链接数据库是必不可少的.之前用vba写过一个售书工具,正好可以拿来 ...
- Oracle中实现sql查询得到连续号码段
一.表名为t的表中数据如下: select * from t; FPHM KSHM ---------- ---------- 实现代码如下: select b.fphm,min(b.kshm),ma ...
- oracle数据库包package小例子
为了把某一个模块的函数.存储过程等方便查询维护,可以把它们打到一个包里.下面给出一个简单的小例子. 1.创建包头 create or replace package chen_pack is func ...
- c/c++ 继承与多态 文本查询的小例子(非智能指针版本)
问题:在上一篇继承与多态 文本查询的小例子(智能指针版本)在Query类里使用的是智能指针,只把智能指针换成普通的指针,并不添加拷贝构造方法,会发生什么呢? 执行时,代码崩掉. 分析下面一行代码: Q ...
- c/c++ 继承与多态 文本查询的小例子(智能指针版本)
为了更好的理解继承和多态,做一个文本查询的小例子. 接口类:Query有2个方法. eval:查询,返回查询结果类QueryResult rep:得到要查询的文本 客户端程序的使用方法: //查询包含 ...
- Oracle存储过程入参传入List集合的小例子
第一步:创建一个对象类型 create or replace type STUDENT as object( id ), name ), age ) ); / 第二步:创建一个数组类型 (任意选择下面 ...
- oracle存储过程的例子
oracle存储过程的例子 分类: 数据(仓)库及处理 2010-05-03 17:15 1055人阅读 评论(2)收藏 举报 认识存储过程和函数 存储过程和函数也是一种PL/SQL块,是存入数据库的 ...
- 【ORACLE】记录通过执行Oracle的执行计划查询SQL脚本中的效率问题
记录通过执行Oracle的执行计划查询SQL脚本中的效率问题 问题现象: STARiBOSS5.8.1R2版本中,河北对帐JOB执行时,无法生成发票对帐文件. 首先,Quartz表达式培植的启 ...
- spring小例子-springMVC+mybits整合的小例子
这段时间没更博,找房去了... 吐槽一下,自如太坑了...承诺的三年不涨房租,结果今年一看北京房租都在涨也跟着涨了... 而且自如太贵了,租不起了.. 突然有点理解女生找对象要房了.. 搬家太 ...
随机推荐
- 你以为在用SharePoint但其实不是
博客地址 http://blog.csdn.net/foxdave 原文链接:http://www.techrepublic.com/blog/tech-decision-maker/you-thin ...
- git 错误 fatal: loose object...is corrupt
错误描述: error: object file .git/objects/9a/83e9c5b3d697d12a2e315e1777ceaf27ea1bab is empty fatal: loos ...
- [Qt] QLineEdit 仿QQ签名框
今天鼓捣了半天,终于实现了自定义Qt中的QlineEdit控件的大致效果. 这个问题对于新手而言,主要有以下几个难点: 1.继承QLineEdit控件 2.QSS设置QLineEdit的相关样式,可以 ...
- SolidWorks 导出工程图时流程
SolidWorks 导出工程图时流程 新建零件装配件制作工程图 设置比例 以前经验发现很我输出的图纸比例不对,需要先设置. 空白处右键,进入属性. 设置图纸比例为 1:1.
- H3C 交换机基本设置(telnet、SSH、链路聚合)
http://www.h3c.com/cn/d_201710/1038172_30005_0.htm#_Toc493869056 H3C S5560S-SI&S5130S-SI[LI]& ...
- github之本地上传
在打算上传到github之前需要在github上面首先创建一个项目(点击右上角“+”号,点击New repository):
- redis 操作大全 PHP-redis中文文档
转自 : http://www.cnblogs.com/weafer/archive/2011/09/21/2184059.html phpredis是php的一个扩展,效率是相当高有链表排序功能, ...
- EF-CodeFirst系列100
.学习资料地址: CodeFirst:https://msdn.microsoft.com/zh-cn/data/jj193542 一.CodeFirst迁移(Migration) .工具--> ...
- Java-Runoob-高级教程-实例-字符串:05. Java 实例 - 字符串反转
ylbtech-Java-Runoob-高级教程-实例-字符串:05. Java 实例 - 字符串反转 1.返回顶部 1. Java 实例 - 字符串反转 Java 实例 以下实例演示了如何使用 J ...
- [Android] 开发第十一天
MainActivity.java 代码如下: package com.oazzz.test9; import android.support.annotation.Nullable; import ...