Mysql sum on total in multiselect -
I want to total and pay off total_price_incl_tax. If I use the first query then I get rows from all the selected columns. It works fine but I only need yoga, so I changed the query. Select
total_price_incl_tax, (SELECT SUM as the sum) from sale invoice as `invoice_payments` for total` invoice_ID` = s.id and invoice_type = 'sale'). It has been sd like ssad Administration_ID = 10605 and `` `` `` `` `` `` `` `` `` `` `and` `` `` `` `` `` `` `` In the form of 'sales' (`total_progress_in_c_taxa` & lt; & gt; (SELECT SUM (` amount`)) (select SUM (sum) `invoice_payment` WHERE` invoice_ID` = s.id and invoice_type =' sale ') The problem in the second link is that the sum of the subkey (payment) is not correct. It has the value of the last line and not the total. SELECT COUNT (*), in the form of the total amount (total_price_incl_tax), (the amount selected from `invoice_payments`` Invoice_id` = s.id and invoice_type = 'sales') As sales have been paid from the sale of S.S. Administration_ID = 10605 and `` `` `` `` and `= 0` and` `` `` `` `` `and` `` ` `` `` `` `` `` `` `(` SELECT SUM (zodiac) 'amount from' invoice_payments' where zodiac Invoice_id` = s.id and invoice_type = 'sale'))
Any idea how this is the only?
simply encapsulate:
SELECT count (*), SUM ( Total_price_incl_tax), from SUM (payment) (select total_progress_in_c_tax), (in the form of selection amount (amount), total `invoice_id` = s.id and invoice_type = 'sales' from` invoices_payments`) such as sales_designs Administration_ID = 10605 and `` `` `''` `` `` `` 1` for `` and `` `` `` `` `and` `total_price_incl_tax`" ``> Amount from 'invoice_payment' in the form of selection amount (`amount`) where` invoice_id = s.id and invoice_p Amount = 'sales') or (from `invoice_payment' in the form of the selection amount (amount) where the amount is` invoice_ID` = s.id and invoice_type = 'sale')) t
Comments
Post a Comment