存储过程MYSQL中的减法
我想看看你是否能帮我,我已经有很多次不使用Mysql了,现在我遇到了一些困难,我需要减去一个量,然后它就会累积起来,我在一个存储过程中这样做: 我希望它显示如下:存储过程MYSQL中的减法,mysql,Mysql,我想看看你是否能帮我,我已经有很多次不使用Mysql了,现在我遇到了一些困难,我需要减去一个量,然后它就会累积起来,我在一个存储过程中这样做: 我希望它显示如下: CREATE DEFINER=`root`@`localhost` PROCEDURE `balance`( in pclient int ) BEGIN declare vbalance decimal(10,2); declare vamount decimal(10,2); SELECT amo
CREATE DEFINER=`root`@`localhost` PROCEDURE `balance`(
in pclient int
)
BEGIN
declare vbalance decimal(10,2);
declare vamount decimal(10,2);
SELECT amount + amount * percent into vbalance FROM credit where amount>0 and id_client= pclient;
select
date,
if(amount>0,amount + amount * percent,amount) amount,
vbalance + amount monto
from
credit
where
id_client=pclient
and id>=(select max(id) id from (SELECT * FROM credit where amount>0 and id_client=pclient) a);
END