DQL查询语句内容整理
select * from t_hq_ryxx; select bianh,xingm from t_hq_ryxx; --为字段名定义别名
select bianh as 编号,xingm as 姓名 from t_hq_ryxx; select bianh 编号 from t_hq_ryxx; select bianh || xingm as 编号和姓名 from t_hq_ryxx; select bianh as bh, t.* from t_hq_ryxx t order by bianh desc; --order by 排序,desc降序排序
select bianh as bh, t.* from t_hq_ryxx t order by xingb desc,bum desc; --nulls last/first的用法,desc或者asc要放在nulls前面
select bianh ,xingm ,bum,xingb from t_hq_ryxx t order by bum desc nulls last,xingb; --选择排序为8的字段
select * from t_hq_ryxx order by 8; --由bum和bianh列来定义排序方式
select * from t_hq_ryxx order by bum || bianh;
--相加的字段若有空则结果为空
select * from t_hq_ryxx order by nianl + gongz; select nianl,gongz, (nianl + gongz) as g from t_hq_ryxx order by (nianl + gongz) desc;
--为字段的和定义别名,并以此为排序定义方式
select nianl,gongz, (nianl + gongz) as g from t_hq_ryxx order by g; select * from t_hq_ryxx;
--选择bum为102或者103,性别为女的行
select * from t_hq_ryxx where (bum = '' or bum = '') and xingb = 2;
--选择bum不为空的行
select * from t_hq_ryxx where bum is not null; --去重复
select distinct bum,xingb from t_hq_ryxx; --模糊查询 % 通配符 _ 通配一位
select * from t_hq_ryxx where xingm like '%阿%'; select * from t_hq_ryxx where bianh in ('','',''); select * from t_hq_ryxx where bianh = '' or bianh = '' or bianh = ''; select * from t_hq_ryxx where gongz between '' and ''; select * from t_hq_ryxx where gongz >= 1000 and gongz <= 2000; --子查询
select * from t_hq_ryxx where bum in (select bumenbm from t_hq_bm where lianxidh = ''); select * from t_hq_ryxx where gongz > all (select pingjgz from t_hq_bm); --分组-
select bum, count(1) as 数量 from t_hq_ryxx group by bum; select bum, count(1) as 数量,avg(gongz) as 平均值,sum(gongz) as 合计 from t_hq_ryxx group by bianh, bum;
--分组基础上过滤
select bum, count(1) as 数量,avg(gongz) as 平均值,sum(gongz) as 合计 from t_hq_ryxx group by bum having avg(gongz) > 2000; select bum, count(1) as 数量,avg(gongz) as 平均值,sum(gongz) as 合计 from t_hq_ryxx where bum is not null group by bum having avg(gongz) > 2000;
DQL查询语句内容整理的更多相关文章
- 6.1课堂笔记—DML(数据操作语言),DQL查询语句
一.DML(数据操作语言) InnoDB MyISAM 支持事务 不支持事务 不支持全文索引 支持全文索引 支持外键约束 不支持 命令查看默认存储引擎 show variables like '%st ...
- DQL查询语句使用(select)
9)DQL查询语句使用 SELECT语句在PL/SQL中使用,必须 采用下面用法: select id INTO 变量 from t001 where id=5; 将记录字段 ...
- SQL中的DQL查询语句
目录 1. DQL:查询语句 排序查询 聚合函数 分组查询 分页查询 2. 约束 3. 多表之间的关系 4. 范式 DQL:查询语句 1. 排序查询 语法:order by 子句 order by 排 ...
- oracle(5)--DQL查询语句
DQL 数据查询语句(data query language) 1.查询条件符号: < , > , = , <= , >= , != , < > ...
- Mysql中的DQL查询语句
----------------1.查询所有列 --查询 学生 表所有记录(行) select *from 学生 --带条件的查询 select *from 学生 where 年龄>19 --- ...
- 关于MySql经典高频查询语句的整理
一查询数值型数据: SELECT * FROM tb_name WHERE sum > 100; 查询谓词:>,=,<,<>,!=,!>,!<,=>,= ...
- SQL结构化查询语句
SQL结构化查询语句 SQL定义了查询所有关系型数据库的规则. 1.通用语法 SQL语句可以单行或者多行书写,以分号结尾 可以使用空格和缩进增强可读性 不区分大小写,但是关键字建议大写 3种注释 注释 ...
- MySQL数据库的创建和基本的查询语句
数据库的定义 数据库是按照数据结构来组织.存储和管理数据的建立在计算机存储设备上的仓库 分类 非结构化数据: 数据相对来说没有固定的特点 半结构化数据: 数据之间有着相同的存储结构 属性 值 每一条数 ...
- 在Delphi中动态地使用SQL查询语句 Adoquery sql 参数 冒号
在Delphi中动态地使用SQL查询语句 在一般的数据库管理系统中,通常都需要应用SQL查询语句来提高程序的动态特性.下面介绍如何在Delphi中实现这种功能.在Delphi中,使用SQL查询语句的途 ...
随机推荐
- python多线程下载
# -*- coding=utf-8 -*- import sys import os import os.path import time import urllib.request, urllib ...
- FragmentPagerAdapter与FragmentStatePagerAdapter区别
在一个 Android 应用中,我使用 FragmentPagerAdapter 来处理多 Fragment 页面的横向滑动.不过我碰到了一个问题,即当 Fragment 对应的数据集发生改变时,我希 ...
- form作为module name 悲剧了
爆出很无语的错误,也怪我,没有实地的debug. 所以,module name应该是不能碰关键词类似,最好custom一点好.
- VC++编译MPIR 2.7.0
目录 第1章编译 2 1.1 简介 2 1.2 下载 3 1.3 解决方案 4 1.4 创建项目 5 1.5 复制文件树 6 1.6 不使用预编译头文件 8 ...
- 鸟哥的linux私房菜勘误表
博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://github.com/jiangxincode 知乎地址: https://ww ...
- AC自动机 & Fail树 专题练习
Fail树就是AC自动机建出来的Fail指针构成的树. [bzoj3172][xsy1713]单词 题意 给定一些单词,求每个单词在所有单词里面的出现次数. 分析 构建Fail树,记录每个单词最后一个 ...
- 【bzoj1046】上升序列
[bzoj1046]上升序列 题意 对于一个给定的S={a1,a2,a3,-,an},若有P={ax1,ax2,ax3,-,axm},满足(x1 < x2 < - < xm)且( a ...
- Azure 云平台用 SQOOP 将 SQL server 2012 数据表导入 HIVE / HBASE
My name is Farooq and I am with HDinsight support team here at Microsoft. In this blog I will try to ...
- License Manager 10.3启动失败解决方法
参考:http://jingyan.baidu.com/article/c275f6bac8763ae33d756788.html 安装ARCGIS10.3过程中无法启动license. 解决办法: ...
- js二级导航
js写二级导航要点 1.ul li 2.js获取元素 3.setInterval(function(),time); 代码如下 <style type="text/css"& ...