Q:

Getting the sum of column grouped by date

Was wondering if there is a way to get the sum of the stock_case column for items with the same date_of_export ? 
Updated with fiddle here and some relevant data: 
https://www.db-fiddle.com/f/szC1Ftj3ZGEC24gSYp6ad4/4
The expected output would be this: 

This is the query used
    SELECT 
    st.product_code,
    st.date_of_export,
    st.best_before_date,
    st.stock_case,
    (
    SELECT 
            SUM(st2.stock_case)
        FROM
            stock_tracking AS st2
            WHERE
            st2.product_code IN ('MGN003')
        AND MONTH(st2.date_of_export) IN (07)
        AND YEAR(st2.date_of_export) IN (2018)
        AND st2.stock_case != 0
    ) AS total
    FROM
    stock_tracking st
WHERE
    product_code IN ('MGN003')
        AND MONTH(st.date_of_export) IN (07)
        AND YEAR(st.date_of_export) IN (2018)
        AND stock_case != 0

and my results

Would like to have a total column like 16, 16, 16, ... , 19, etc
For another case I used a subquery like so
SELECT 
    d.products_name,
    stock_case,
    st.date_of_export,
    st.best_before_date,
    st.product_code,
    (SELECT 
            SUM(st2.stock_case)
        FROM
            stock_tracking AS st2
        WHERE
            DATE(st2.date_of_export) = (SELECT 
                    DATE(tmp.last_update)
                FROM
                    (SELECT 
                        date_of_export AS last_update
                    FROM
                        stock_tracking
                    ORDER BY date_of_export DESC
                    LIMIT 1) AS tmp
                WHERE
                    product_code = 'MGN003')) AS total
FROM
    stock_tracking st
        LEFT JOIN
    products AS p ON p.products_model = st.product_code
        LEFT JOIN
    products_description AS d ON d.products_id = p.products_id
WHERE
    product_code = 'MGN003'
        AND d.language_id = 2
        AND DATE(st.date_of_export) = (SELECT 
            DATE(tmp.last_update)
        FROM
            (SELECT 
                date_of_export AS last_update
            FROM
                stock_tracking AS st
            ORDER BY date_of_export DESC
            LIMIT 1) AS tmp)

with this result:

A:

You can write a subquery to sum(stock_case)  by date_of_export, then self join on Date, then you can get your expect result.
SELECT  
    s.product_name,
    s.date_of_export,
    s.best_before_date,
    s.product_code,
    s.stock_case,
    t.totle
FROM
    stock_tracking s
INNER JOIN
    (
        SELECT SUM(stock_case) totle,date_of_export dt
       FROM stock_tracking
       where   
        product_code = 'MGN003'
        AND MONTH(date_of_export) =07
        AND YEAR(date_of_export) =2018
        AND stock_case != 0
      GROUP BY date_of_export
    ) t on DATE_FORMAT(s.date_of_export, "%d-%m-%Y") = DATE_FORMAT(t.dt, "%d-%m-%Y")
where 
    s.product_code = 'MGN003'
AND MONTH(s.date_of_export) =07
AND YEAR(s.date_of_export) =2018
AND s.stock_case != 0

sqlfiddle

