Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
月 (yyyy-mm)、開始、借方、貸方、終了を月 (yyyy-mm) ごとのトランザクション グループから選択したいと思います。
取引表はこちら
日付、借方、貸方
phpなしでmysqlだけで可能ですか?
最も簡単な方法は、次のように変数を使用することです。
select `date`, debit, credit, (@bal := credit - debit) as bal from transaction t cross join (select @bal := 0) const order by `date`;
その後、これを集計ややりたいことに使用できます。