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 基本函数小例子--查询身高段分数段的更多相关文章

  1. vb.net写的odbc连接dsn数据源和ole链接oracle的小例子

    最近由于工作需要开始接触vb2010,也叫vb.net.相比vb6.0有面向对象编程的优势.同时接触一门新语言,要更快的实际应用起来,链接数据库是必不可少的.之前用vba写过一个售书工具,正好可以拿来 ...

  2. Oracle中实现sql查询得到连续号码段

    一.表名为t的表中数据如下: select * from t; FPHM KSHM ---------- ---------- 实现代码如下: select b.fphm,min(b.kshm),ma ...

  3. oracle数据库包package小例子

    为了把某一个模块的函数.存储过程等方便查询维护,可以把它们打到一个包里.下面给出一个简单的小例子. 1.创建包头 create or replace package chen_pack is func ...

  4. c/c++ 继承与多态 文本查询的小例子(非智能指针版本)

    问题:在上一篇继承与多态 文本查询的小例子(智能指针版本)在Query类里使用的是智能指针,只把智能指针换成普通的指针,并不添加拷贝构造方法,会发生什么呢? 执行时,代码崩掉. 分析下面一行代码: Q ...

  5. c/c++ 继承与多态 文本查询的小例子(智能指针版本)

    为了更好的理解继承和多态,做一个文本查询的小例子. 接口类:Query有2个方法. eval:查询,返回查询结果类QueryResult rep:得到要查询的文本 客户端程序的使用方法: //查询包含 ...

  6. Oracle存储过程入参传入List集合的小例子

    第一步:创建一个对象类型 create or replace type STUDENT as object( id ), name ), age ) ); / 第二步:创建一个数组类型 (任意选择下面 ...

  7. oracle存储过程的例子

    oracle存储过程的例子 分类: 数据(仓)库及处理 2010-05-03 17:15 1055人阅读 评论(2)收藏 举报 认识存储过程和函数 存储过程和函数也是一种PL/SQL块,是存入数据库的 ...

  8. 【ORACLE】记录通过执行Oracle的执行计划查询SQL脚本中的效率问题

    记录通过执行Oracle的执行计划查询SQL脚本中的效率问题   问题现象: STARiBOSS5.8.1R2版本中,河北对帐JOB执行时,无法生成发票对帐文件.   首先,Quartz表达式培植的启 ...

  9. spring小例子-springMVC+mybits整合的小例子

    这段时间没更博,找房去了...   吐槽一下,自如太坑了...承诺的三年不涨房租,结果今年一看北京房租都在涨也跟着涨了... 而且自如太贵了,租不起了.. 突然有点理解女生找对象要房了..   搬家太 ...

随机推荐

  1. 這是我既C語言作業寫博客後寫的第一篇博客

    這篇博客應該算是寫給我自己的博客吧,所以這裏我想用繁體字寫,因為我漸漸地發現我已經很少使用到繁體字了,日常QQ聊天都使用簡體字,繁體字都懶得切換了,但是為了不讓別人麻煩,在外界交流的時候我會使用簡體字 ...

  2. python(五):面向对象--类和实例

    一.类的基本概念 类是用来创建数据结构和新类型对象的主要机制.一个类定义了一系列与其实例对象密切关联的属性.典型的属性包括变量(也被称为 类变量)和函数(又被称为方法). 1.class上下文 cla ...

  3. 重新学习之spring第一个程序,配置IOC容器

    第一步:导入相关jar包(此范例导入的是spring3.2.4版本,spring2.5版本只需要导入spring核心包即可) 第二步:在项目的src下配置applicationContext.xml的 ...

  4. chaos-engineering 的一些开源工具

    Chaos Monkey - A resiliency tool that helps applications tolerate random instance failures. The Simi ...

  5. 每天进步一点点——Linux中的线程局部存储(一)

    转载请说明出处:http://blog.csdn.net/cywosp/article/details/26469435    在Linux系统中使用C/C++进行多线程编程时,我们遇到最多的就是对同 ...

  6. 在AD中存取照片

    AD中有存放照片的字段吗? 答案肯定是有的.photo,jpegPhoto,thumbnailPhoto 前端时间客户,包括领导 在问通讯录中的照片为什么存在数据库中而不是AD中,AD中的属性能不能利 ...

  7. linux中查看nginx、apache、php、mysql配置文件路径的方法

    如何在Linux中查看nginx.apache.PHP.MySQL配置文件路径了,如果你接收一个别人配置过的环境,但没留下相关文档.这时该怎么判断找到正确的加载文件路径了.可以通过以下来判断1.判断a ...

  8. SCSI协议

    SCSI是一套完整的数据传输协议,其主要功能是在主机和存储设备之间传送命令.状态和块数据.在各类存储技术中,SCSI技术可谓是最重要的脊梁. SCSI协议位于操作系统和外部资源之间,它具有一系列的功能 ...

  9. bzoj 3059: 归途与征程

    Description 给出一个长度为N的由小写字母’a’~’z’和’*’组成的字符串A,一个长度为M的仅由小写字母’a’~’z’组成的字符串B.一个’*’可以匹配任意多个字符(包括0个).求在B的所 ...

  10. [C#][控件]WebBrowser 使用范例

    if (webInfo.Document != null) webInfo.Document.OpenNew(true); else webInfo.Navigate("about:blan ...