feat: refs #6500 procRefactor8 #2131
|
@ -17,27 +17,27 @@ BEGIN
|
||||||
DROP TEMPORARY TABLE IF EXISTS tCreditClients;
|
DROP TEMPORARY TABLE IF EXISTS tCreditClients;
|
||||||
CREATE TEMPORARY TABLE tCreditClients
|
CREATE TEMPORARY TABLE tCreditClients
|
||||||
SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit
|
SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit
|
||||||
robert marked this conversation as resolved
Outdated
|
|||||||
FROM (
|
FROM (
|
||||||
robert marked this conversation as resolved
Outdated
carlosap
commented
tabulación FROM tabulación FROM
|
|||||||
SELECT r.clientFk,
|
SELECT r.clientFk,
|
||||||
r.amount recovery,
|
r.amount recovery,
|
||||||
(sub2.created + INTERVAL r.period DAY) deadLine,
|
(sub2.created + INTERVAL r.period DAY) deadLine,
|
||||||
robert marked this conversation as resolved
Outdated
carlosap
commented
INTERVAL INTERVAL
|
|||||||
sub2.amount credit
|
sub2.amount credit
|
||||||
FROM recovery r
|
FROM recovery r
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT clientFk, amount, created
|
SELECT clientFk, amount, created
|
||||||
FROM (
|
FROM (
|
||||||
SELECT clientFk, amount, created
|
SELECT clientFk, amount, created
|
||||||
robert marked this conversation as resolved
Outdated
carlosap
commented
Especificar campos, eliminar * Especificar campos, eliminar *
|
|||||||
FROM clientCredit
|
FROM clientCredit
|
||||||
ORDER BY created DESC
|
ORDER BY created DESC
|
||||||
LIMIT 10000000000000000000
|
LIMIT 10000000000000000000
|
||||||
) sub
|
) sub
|
||||||
GROUP BY clientFk
|
GROUP BY clientFk
|
||||||
) sub2 ON sub2.clientFk = r.clientFk
|
) sub2 ON sub2.clientFk = r.clientFk
|
||||||
WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE()
|
WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE()
|
||||||
GROUP BY r.clientFk
|
GROUP BY r.clientFk
|
||||||
robert marked this conversation as resolved
Outdated
carlosap
commented
tabulación HAVING tabulación HAVING
|
|||||||
HAVING deadLine <= util.VN_CURDATE()
|
HAVING deadLine <= util.VN_CURDATE()
|
||||||
) sub3
|
) sub3
|
||||||
WHERE credit > 0;
|
WHERE credit > 0;
|
||||||
|
|
||||||
UPDATE client c
|
UPDATE client c
|
||||||
robert marked this conversation as resolved
Outdated
carlosap
commented
tabulación JOIN y SET tabulación JOIN y SET
|
|||||||
JOIN tCreditClients cc ON cc.clientFk = c.id
|
JOIN tCreditClients cc ON cc.clientFk = c.id
|
||||||
|
|
Loading…
Reference in New Issue
Espacios: SELECT clientFk, IF (credit > recovery, credit - recovery, 0) newCredit