1.mod 나머지를 알려줌 -> mod(값, 나눌 수)
1
2
3
4
5
|
--1)mod: 나머지 -> mod(값, 나눌 수)
select mod(7, 3) from dual;
select * from professor;
select pay, mod(pay, 100) as "100으로 나눈 급여" from professor;
|
cs |
2.nvl 값에 null이 있으면 대체값으로 변경 -> nvl(값, 대치값)
1
2
3
4
5
6
7
8
9
10
11
|
--2)nvl 함수: nvl(값, 대치값) - 값에 null이 있으면 대치값으로 변경한다
select name, bonus, bonus + 100 from professor; --null연산은 연산해도 null
update professor set bonus = bonus + 100; --null연산은 update해도 null
select name, bonus, bonus + 100 from professor;
--해결)
select name, bonus, nvl(bonus, 0) from professor;
select name, bonus, nvl(bonus, 0)+5000 from professor;
update professor set bonus = nvl(bonus, 0) + 3000;
|
cs |
cf)null은 연산이나 update해도 변하지 않고 null값임
'Database > Basic' 카테고리의 다른 글
between, order by(오름차순과 내림차순) (0) | 2021.02.08 |
---|---|
조건연산자(like, or, and, in, between, any, all, not, null) (0) | 2021.02.08 |
null과 ' ' (0) | 2021.02.07 |
중복행제거 distinct (0) | 2021.02.07 |
레코드 삽입, 수정, 삭제 (0) | 2021.02.07 |