the solution is to apply an aggregate function to these columns
I had a view on “(Aggregate) Functions” in MySQL documentation and regard to your hints I choosed SUM() function for aggregation and my deduction was drived from this assumption :
Every ~NULL~ value in each group should be summed with its tantamount ~not NULL~ value .
So I modified the query like below and of course the drived result is correct now :agree:
SELECT ft.leafCode
,ft.leafName
,ft.colorsCode
[COLOR="Blue"] ,SUM(pack) AS `pack`[/COLOR]
[COLOR="Blue"] ,SUM(warehouse) AS `warehouse`[/COLOR]
FROM (
[COLOR="Silver"] ---here are subqueries---[/COLOR]
) AS ft
GROUP BY ft.leafCode
,ft.leafName
,ft.colorsCode;
Dear r937 , now final result is right but is my deduction right too ?