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;
Oracle 关系运算符在 where条件语句当中经常使用到,常用的关系如下:
| 符号 | 解释 | 符号 | 解释 |
|---|---|---|---|
| = | 等于 | <>或者!= | 不等于 |
| > | 大于 | >= | 大于或者等于 |
| < | 小于 | <= | 小于或者等于 |
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'