1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
select abs(sum(case when purchase=2 then -money else money end))
from cart
where user_id=202;
sum케이스문 abs(절대값)
select sum(case when purchase=2 then -money else money end)
from cart
where user_id=202;
원하는 값을 출력 확인을 위한 쿼리문
select abs(sum(money))
from cart
where user_id=202 and purchase=1;
절대값 확인을 위한
|
cs |
'DB자료' 카테고리의 다른 글
리눅스에서 mysql-> 루프에 갖혀있을 경우 (0) | 2020.02.14 |
---|---|
Create Table (0) | 2019.08.02 |
마이크로 sql Server 2014 Express (0) | 2019.07.03 |
MongoDB와 Sql의 차이 (0) | 2019.07.02 |
dataSource - context (0) | 2019.05.23 |