Hello. Tell me. There is a table that is generated in SQL format.
код товара | наименование | закуп | прод| 001 | товар1 | 5 | 4 | The first two columns in the row are displayed in my usual Select, and where the purchase and prol is considered the sum in other tables and the total value is displayed.
SELECT COALESCE(SUM(quant), 0.0) AS quant FROM paid_items, paid WHERE paid.record_type=-1 One column counts -1, the second +1. I want to be sorted as a result of the third column. From more to less, but I can’t understand how to correctly specify sorting, I tried to thrust this condition completely into ORDERS BY, but nothing, of course, helped
ORDER BY COALESCE(SUM(quant), 0.0)- vikolyada