首页 技术 正文
技术 2022年11月8日
0 收藏 479 点赞 1,746 浏览 2260 个字
--精确查找:查询水表编号为30408的业主记录
SELECT * FROM T_OWNERS WHERE WATERMETER = ''
--模糊查询:查询业主名称包含'刘'的业主记录
SELECT * FROM T_OWNERS WHERE NAME LIKE '%刘%'
--AND运算符:查询业主名称包含'刘'的并且门牌号包含5的业主记录
SELECT * FROM T_OWNERS WHERE NAME LIKE '%刘%' AND HOUSENUMBER LIKE '%5%'
--or运算符:查询业主名称包含'刘'的或者门牌号包含5的业主记录
select * from t_owners where name like '%刘%' or housenumber like '%5%'
--and与or混合使用:查询业主名称包含'刘'的或者门牌号包含5的业主记录,并且地址编号为3的记录
select * from t_owners where (name like '%刘%' or housenumber like '%5%') and addressid = 3
--范围查询:查询台账记录中用水字数大于等于10000并且小于等于20000的记录
select * from t_account where usenum>=10000 and usenum<=20000
select * from t_account where usenum between 10000 and 20000
--空值查询:查询t_pricetable 表中maxnum为空的记录
select * from t_pricetable where maxnum is null
--不为空
select * from t_pricetable where maxnum is not null
--去重:查询业主表中的地址ID 不重复显示
select distinct addressid from t_owners--聚合统计
--求和sum:统计2012年所有用户的用水量总和
select sum(usenum) from t_account where year = ''
--求平均数avg:统计2012年所有用水量的平均值
select avg(usenum) from t_account where year = ''
--求最大值max:统计2012年最高用水量
select max(usenum) from t_account where year = ''
select min(usenum) from t_account where year = ''
--统计记录数count:统计业主类型ID为1的业主记录
select count(*) from t_owners where ownertypeid = 1
--分组聚合:按区域分组统计水费合计数
select areaid,sum(money) from t_account group by areaid
--分组后条件查询having:查询水费合计大于16900的区域及水费合计
select areaid,sum(money) from t_account group by areaid having sum(money)>16900--集合运算
--并集(包含重复记录)
select * from t_owners where id>5
union all
select * from t_owners where id<8
select * from t_owners where id>5
union
select * from t_owners where id<8
--交集
select * from t_owners where id>5
intersect
select * from t_owners where id<8
--差集
select * from t_owners where id>5
minus
select * from t_owners where id<8
select * from t_owners where id<8
minus
select * from t_owners where id>5--序列
--创建简单序列
create sequence seq_test1;
--查询序列的下一个值
select seq_test1.nextval from dual;
--查询序列的当前值
select seq_test1.currval from dual;
--创建一个有最大值的非循环序列
create sequence seq_test2 maxvalue 5;
select seq_test2.nextval from dual;
--自定义增长值
create sequence seq_test3
increment by 10
start with 10
maxvalue 100
select seq_test3.nextval from dual;
--有最小值的序列
create sequence seq_test4
increment by 10
start with 10
minvalue 5
maxvalue 100
select seq_test4.nextval from dual;
--循环序列
create sequence seq_test5
increment by 10
start with 10
minvalue 10
maxvalue 210
cycle
select seq_test5.nextval from dual;--同义词
--创建私有同义词
create synonym owner for t_owners;
select * from owner
select * from wateruser.t_owners
--创建公有同义词
create public synonym owner2 for t_owners;
select * from owner2
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,092
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,568
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,416
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,189
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,825
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,908