5select的运用
四、select的运用
--汇总函数 max()最大值,min()最小值,avg()平均值
select max(age),min(age),avg(age) from tablename; --算出表中age的最大值,并非全部max(age)数据
select max(age),min(age),avg(age) from tablename where id!=1;
select * from tablename where max(age); --错误
--子查询 返回的是最大值
select *from tablename where age in(select max(age) from tablename);
select max(age)from tablename where age in(select max(age) from tablename);
--查询最小值到最大值之间的全部数据
select* from malestaff where age
between (select MIN(age) from malestaff) and (select MAX(age) from malestaff);
select count(*) form tablename --统计人数
--分组 根据id的不同进行分组
select * from tablename group by id;
--排序 根据id的不同进行排序,默认为升序,desc代表降序
select * from tablename order by id;
select * from tablename order by id desc;
--多种条件约束
select * from tablename
where age is not null --查询条件
group by age --分组字段 where意义等同于having
having count(*)>2 --分组条件 即相同age的人数〉2
order by count(*); --根据人数的不同,对查询数据进行升序
5select的运用的更多相关文章
- Mysql - 查询之关联查询
查询这块是重中之重, 关系到系统反应时间. 项目做到后期, 都是要做性能测试和性能优化的, 优化的时候, 数据库这块是一个大头. sql格式: select 列名/* from 表名 where 条件 ...
- hiberante学习笔记
1.配置文件(hibernate映射文件): 让hibernate知道该怎么样去load,store持久化对象: 1.1 数据库忌讳的字段名 1) User 2) index 2.数据库表中一对多,多 ...
- linux设备驱动归纳总结(三):6.poll和sellct【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-61749.html linux设备驱动归纳总结(三):6.poll和sellct xxxxxxxxxx ...
- Linq To Sql 语法 子查询 & In & Join
子查询 描述:查询订单数超过5的顾客信息 查询句法: var 子查询 =from cin ctx.Customers where ...
- Thread: BooleanRT : Realtime 3D boolean operations for (Runtime,Editor)
A Product by Mixed Dimensions What is BooleanRT? BooleanRT is a real-time 3D boolean operations exte ...
- 这里的*号实际表示就是RAC中所有实例都使用
您的位置: ITPUB个人空间 » cc59的个人空间 » 日志 发布新日志 我的日志我的足迹我的收藏 unix/linuxHA随笔backup&restoreperformance tuni ...
- Oracle中join left,join right,inner join,(+) 等
Oracle中join left,join right,inner join,(+) 等 博客分类: Oracle 建表create table TEST1create table TEST1( ...
- 常用oracle中系统表查询语句
sqlplus / as sysdbaSQL>select status from v$instance;1.查看最大连接数show parameter processes;2.查询oracle ...
- AltiumDesigner PCB导入CAD
点击File菜单下的New的PCB,新建PCB文件. 在AD09中点击File菜单下的Import,导入CAD文件 选择要导入的CAD文件,点击打开. 选择单位mm,这里的单位选择要与CAD单位一致, ...
随机推荐
- vue钩子生命周期
1.beforeCreate // 组件实例刚刚被创建2.created // 实例已经创建完成3.beforeMount // 模板编译之 ...
- python--利用列表推导式快速生成xml格式数据
在接口自动化测试中,我们经常将要发送的数据放到excel里. json数据放至excel方便,但最近的一个测试,数据是xml格式发送的 如下: 属性 必选/可选 描述 1. Message Eleme ...
- 51nod 1126 - 求递推序列的第N项 - [找规律]
题目链接:https://cn.vjudge.net/problem/51Nod-1126 有一个序列是这样定义的:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + ...
- codeforces 883H - Palindromic Cut - [字符串处理]
题目链接:http://codeforces.com/problemset/problem/883/H Time limit: 3000 ms Memory limit: 262144 kB Koly ...
- FaceBook开源的词向量计算框架
fasttext是个好东西,是由facebook在2016年推出的一个训练词向量的模型.相比于之前Google的word2vec,fasttext可以解决out of vocabulary的问题.fa ...
- NTLM
我们介绍Kerberos认证的整个流程.在允许的环境下,Kerberos是首选的认证方式.在这之前,Windows主要采用另一种认证协议——NTLM(NT Lan Manager).NTLM使用在Wi ...
- HTML5 Storage(永久存储)
localStorage.aa="aa"; //存储了一个key为aa并且value为aa的键值对: localStorage.setItem("bb", &q ...
- Python开发【笔记】:python程序添加到systemctl系统服务
systemctl系统服务 环境:centos7 systemctl服务使用详解 实现 正常情况下我们在/usr/lib/systemd/system/目录下,创建一个以.service 后缀的文件, ...
- CentOS7 firewall防火墙配置笔记
开启端口 # firewall-cmd --zone=public --add-port=/tcp --permanent 命令含义: --zone #作用域 --ad ...
- 【虫师】【selenium】参数化
# 1 #coding=utf-8 from selenium import webdriver import os,time source = open("F:\\test\\info.t ...