There are two subqueries. Both return tables of the form:
код_товара | SUM(колво_поступило) код_товара | SUM(колво_продали) which are calculated from different tables.
How to combine the results of these subqueries with the table товары :
код_товара | наименование_товара so that you can select in the main query:
SELECT наименование_товара, (колво_поступило)-(колво_продали) AS осталось FROM товары JOIN --подставить результат подзапросов ... HAVING осталось>0 ?
If we directly substitute the subqueries in the JOIN with the table товары , then phpMyAdmin immediately swears at the invalid syntax of such a JOIN.