连接运算符oracle,Oracle 运算符与连接符

一、Oracle运算符

Oracle运算符包括算术运算符、关系运算符和逻辑运算符。

案例展示所需表结构如下(建表所需SQL语句点击这里):

3b42e87cf58f244fdc613f5113009f37.png

1、Oracle算术运算符

Oracle算术运算符包括+、-、*、/四个,其中/获得的结果是浮点数。

案例1、求2018年上学期数学的平均成绩。select a.*, b.coursename, c.stuname

from score a, course b, stuinfo c

where a.courseid = b.courseid

and a.stuid = c.stuid;

select b.coursename, sum(a.score) / count(1)

from score a, course b

where a.courseid = b.courseid

and a.courseid = 'R20180101'

group by b.coursename;

结果如下:

53d0bdef2ae97bb7ea58d12f943522a5.png

2、Oracle关系运算符

Oracle关系运算符在where条件语句当中经常使用到,常用的关系如下:符号解释符号解释

=等于<>或者!=不等于

>大于>=大于或者等于

3、Oracle逻辑运算符

Oracle的逻辑运算符有三个:AND、OR、NOT。

案例2、查看2018年上学期数学成绩在85-95分之间的同学:select a.*, b.coursename, c.stuname

from score a, course b, stuinfo c

where a.courseid = b.courseid

and a.stuid = c.stuid

and a.score >= '85'

and a.score <= '95'

结果如下:

a72389410f0f7bb7c47e5eaeedc45499.png

二、Oracle 字符串连接符||

Oracle中利用字符串连接符||(即双竖线)来连接查询结果。

案例、字符串连接符||:select '姓名:' || c.stuname || ', 课程:' || b.coursename || ', 成绩:' || a.score || '分。' as sxcj

from score a, course b, stuinfo c

where a.courseid = b.courseid

and a.stuid = c.stuid

结果如下:

9d89097879177cb2a04ae1e7f8fda017.png

转载本站内容时,请务必注明来自W3xue,违者必究。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值