我试图了解 MySQL 存储过程,但我不了解YEAR_MONTH
. 这意味着INTERVAL '0-0'
YEAR_MONTH 和INTERVAL '0-4' YEAR_MONTH
?它是用来做什么的?
对存储过程的查询是这样的:
SELECT remunerations.id_princ,
remunerations.id_cont,
customer.t_contraco,
remunerations.id_ct,
ABS(SUM(remunerations.item1)) AS item1,
ABS(SUM(remunerations.item2)) AS item2,
ABS(SUM(remunerations.item3)) AS item3
FROM customer
RIGHT OUTER JOIN remunerations ON (customer.id_cont = remunerations.id_cont)
RIGHT OUTER JOIN contractuals ON (remunerations.id_ct = contractuals.id_ct)
WHERE remunerations.id_princ = var_princ AND
customer.active_cont = 1 AND
customer.deactive_princ = 1 AND
DATE_FORMAT(CONCAT(remunerations.anyo_trab, '-', remunerations.mes_trab, '-15'), "%Y-%m-%d") IN ((
SELECT DATE_SUB(CONCAT(MAX(rm.anyo_trab),'-', MAX(rm.mes_trab),'-15'), INTERVAL '0-0' YEAR_MONTH) AS fecha2
FROM
remunerations rm
WHERE rm.anyo_trab = YEAR (date_sub (NOW(), INTERVAL '0-4' YEAR_MONTH)) AND
rm.id_princ = var_princ AND
rm.id_cont = remunerations.id_cont
)) AND
(remunerations.finiquito_planilla IS NULL OR remunerations.finiquito_planilla >= var_fecha)
GROUP BY remunerations.id_princ,
remunerations.id_cont,
customer.elorden,
remunerations.id_ct;