Hi have a very simple table with data. I need to extract the Quantities for each MinorCode but these quantities should be the sum of the quantities only if a MinorCode has the same ParentCode and not the Quantities as per each record in the table.
For example MinorCodes OGHYLD and OGHYLDUS share the same ParentCode FOGHYLD therefore in my results I need to see the sum total of 152,162 (81,260 plus 70,902) as the Quantity for OGHYLD and OGHYLDUS. Some records to dot share a ParentCode therefore no SUM required.
Table data & Expected results:
I have tried a simple sum and group by but it does not give me the correct results.
SELECT MinorCode as Code, sum(Quantity) AS Quantity
GROUP BY Parent
How would I specify the above requirement in order to show the SUM of the respective MinorCode Quantities if they share the same ParentCode?