I have a table named common_leger, from which I need to run to show the balance between Dramant, CR_Amount and them. This is the reason I have written a question below. But I'm getting the result of every query as if the current row's balance But I have to produce results with the remaining balance. Let's say the first row of the drum balan is 20000 and the crawlance is 5000 and the rest is 15000. In the second line, only CrabBlalance is 5000. Now the result should be 10000 with deduction, but my result is -5000. I have no idea how to fix this. Can anyone help me on this? I need a lot of help from you here my query is given below:
SELECT "as cost_center_id," AS cost_center_name ", AS office code, convert ('2013-02-01', DATETIME) in 'as Lenden_det,' 'accounts_head_id,' as' ACCOUNT_NAME, '' as opposite_accounts_head_id, 'as' opposite_account_name,' opening balance 'details, tempOpeningBalance.dr_amount, tempOpeningBalance.cr_amount, As the 'voucher_no,' in the form of Win (Selection IFNULL ('1101010101100321' as mcoa.account_code) as ACCOUNT_CODE, IFNULL (mcoa.account_name, 'cache') form of ACCOUNT_NAME In the form of dr_amount, IFNULL (mcoa.account_type, 'asset'), ACCOUNTTYPE, CAST (IFNULL (sum (IFNULL (as in maingl.dr_balance, 0)), 0) as decimal (27,5) Cast (IFNULL (IFNULL (IFNULL (maingl.cr_balance, 0)), 0) decimal (27,5)) from master_chart_of_accounts as cr_amount as in the form of mcoa inner chart_of_accounts COA included on (mcoa.id = coa.master_chart_of_accounts_id and mcoa.id = 80) left join General_ledger select AS maingl ON (coa.id = maingl.accounts_head_id and coa.account_code = '1101010101100321') join insider (gl.accounts_head_id, Max (gl.gl_id ) As max_gl_id, gl.office_code, gl.office_type, gl.country_id, gl .cost_center_id general_ledger by GL form - Join voucher_info as gl.voucher_info_id = vi on inner vi (id .id) - WHERE vi.posting_date & lt; '2013-02-01' and WHERE gl.transaction_date & lt; '2013-02-01' and gl.cost_center_id IN ('BI0000000000000000000001') and gl.country_id IN (1) and gl.office_code IN ('UG500013') and 1 = 1 group by gl.accounts_head_id, gl.office_code, gl .office_type, gl.country_id, gl.cost_center_id by order gl_accounts_head_id) at AS tmpgl (maingl.office_code = tmpgl.office_code and maingl.office_type = tmpgl.office_type and maingl.accounts_head_id = tmpgl.accounts_head_id and maingl.country_id = tmpgl. country_id and maingl.cost_center_id = tmpgl.cost_center_id and maingl.gl_id = tmpgl.max_gl_id) select temporarily banking union as WHERE mcoa.account_status_id = 1 and coa.account_status_id = 1) as vi.cost_center_id, cc.center_name Transaction_date, cost_center_name, gl.office_code, vi .posting_date, vd.accounts_ Head_id, (Chart_off_counts select chart_off_counts WHERE chart_of_accounts.id = vd.accounts_head_id) AS account_name, vd.opposite_accounts_head_id, (select chart_ of_accounts.account_name chart_of_accounts WHERE c hart_of_accounts.id = vd.opposite_accounts_head_id) opposite_account_name, vd.particulars, gl as as .dr_amount dr_amount - to check here, gl.cr_amount as cr_amount, vi.voucher_no, vi.vin general_ledger JL voucher_info as inner vi JOIN (gl.voucher_info_id = vi.id ) Join Insiders at cost_center CC (vi.cost_center_id = cc.id) Join Inside voucher_details on vd Inner form (vi.id = vd.voucher_info_id) join chart_of_accounts as COA (vd.accounts_head_id = COA.ID) WHEER vi.posting_date between '2013-02-01' AND'2013-02-28 ' and vi.voucher_status_id = 3 and vd.status_id = 1 and vi.office_code = 'UG500063' and coa.account_code = '1101010101100321' and coa.cost_center_id = 'BI0000000000000000000001 cost_center_name by orders orders, office_code, transaction_date;
Use a variable like this
SET @ running_balance = 0; SELECT dr_amount as dr_amount, cr_amount as cr_amount, @running_balance: = (@running_balance + dr_amount - cr_amount) General_logger
No comments:
Post a Comment