Last active
June 25, 2022 09:43
-
-
Save ebta/22584b01710a3d379f6fe3f3c5cc8f11 to your computer and use it in GitHub Desktop.
Query menghitung balance (saldo) di MySQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @saldo = 3000000; | |
SELECT id_sample, uraian, debet, kredit, (@saldo := @saldo + (debet - kredit)) as Saldo | |
FROM sample; | |
-- Alternatif as one query statements | |
SELECT s.id_sample, s.uraian, s.debet, s.kredit, (@saldo := @saldo + (s.debet - s.kredit)) as Saldo | |
FROM (SELECT @saldo := 3000000) AS dummy | |
CROSS JOIN sample s; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bang, bagaimana kalo datanya sudah banyak, dan cara agar query nya tidak lambat?