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整合的小例子
这段时间没更博,找房去了... 吐槽一下,自如太坑了...承诺的三年不涨房租,结果今年一看北京房租都在涨也跟着涨了... 而且自如太贵了,租不起了.. 突然有点理解女生找对象要房了.. 搬家太 ...
随机推荐
- 《转》深入理解Activity启动流程(一)–Activity启动的概要流程
本文原创作者:Cloud Chou. 原文地址:http://www.cloudchou.com/android/post-788.html Android中启动某个Activity,将先启动Acti ...
- Win7操作系统安装IE10提示“安装前需要更新与安装程序版本”
安装IE10浏览器时提示错误的 Internet Explorer安装程序版本 故障现象: Win7操作系统在安装IE10浏览器时会弹出对话框,提示错误的Ieternet Explorer 安装程序版 ...
- Android sdk 更新后编译不过,【Could not find com.android.sdklib.build.ApkBuilderMain】
最近更新了Android sdk,发现编译不过了 解决方案: 进入 sdk/tool/lib/ 目录下,看看有没有 sdklib.jar 这个文件,如果没有看看有没有sdklib-25.*.*.jar ...
- resin WED服务器初用遇到的问题和解决方法 java.lang.RuntimeException: java.net.SocketException: Unrecognized Windows Socke ts error: 0: JVM_Bind
开启resin 服务器以后提示如下:(控制台不断的循环循环打印如下错误提示) java.lang.RuntimeException: java.net.SocketException: Unrecog ...
- gradle 代理设置
可以对gradle全局设置变量,也可以针对单个项目进行配置. 只需要在.gradle目录下创建一个gradle.properties文件,文件中按照如下格式添加代理配置 systemProp.http ...
- 升级到SQL Server 2012/2014时一些需要考虑的事项
1. 使用Upgrade Adviser评估升级前需要解决的事情. https://msdn.microsoft.com/zh-cn/library/ms144256(v=sql.110).aspx ...
- python api接口认证脚本
import requests import sys def acces_api_with_cookie(url_login, USERNAME, PASSWORD, url_access): ...
- macOS --- 配置基于域名的虚拟主机
在终端运行 sudo vi /Applications/XAMPP/xamppfiles/etc/httpd.conf,打开apache配置文件. 在httpd.conf中找到"#Inclu ...
- FastAdmin 插件配置文件 info.ini 中的 state 什么意思?
FastAdmin 插件配置文件 info.ini 中的 state 什么意思? 在插件配置中有一个 state ,这是配置插件开关的.
- Chrome 解决flash问题
Chrome 无法显示使用插件的内容 Chrome 不再支持很多插件.不过网站创建者已经通过更安全的方式,将多数这类功能添加到 Chrome 中. 为什么 NPAPI 插件现在无法正常运行过去,许多插 ...