Skip to content

Tag: window-functions

MySQL Debit/Credit cumulative balance

I would like a cumulative DR or CR balance for the following table: For the above table, a cumulative Balance column would be: Decreasing a DR below 0 makes it a CR Decreasing a CR below 0 makes it a DR Where balance is 0, value is 0 DR It could be calculated as CR’s being a negative value, but

How to get the row index in SQLite3?

I have created a table that has a column of registration number as primary key. I have created row_id using row_number() that is ordered by the primary key. How can i search a registration number and get the row_id along with other information of that row? Answer If you have created the column row_id like: th…