So simple, yet so beautiful.

It does something, believe me.

SELECT 
    products.code,
    stock.id,
    products.id AS pid,
    stock.product_incoming AS 'in',
    stock.product_outgoing AS 'out',
    stock.product_remain AS 'rem',
    (SELECT 
            sum(receiving_items.quantity)
        FROM
            receiving_items,
            receivings
        WHERE
            receiving_items.receiving_id = receivings.id
                AND receiving_items.product_id = products.id
                AND (MONTH(receivings.rv_date) = 9
                AND YEAR(receivings.rv_date) = 2013)) AS 'in@9',
    (SELECT 
            sum(invoice_items.quantity)
        FROM
            invoice_items,
            invoices
        WHERE
            invoice_items.invoice_id = invoices.id
                AND invoice_items.product_id = products.id
                AND (MONTH(invoices.inv_date) = 9
                AND YEAR(invoices.inv_date) = 2013)) AS 'out@9',
    (SELECT 
            sum(receiving_items.quantity)
        FROM
            receiving_items,
            receivings
        WHERE
            receiving_items.receiving_id = receivings.id
                AND receiving_items.product_id = products.id
                AND (MONTH(receivings.rv_date) = 10
                AND YEAR(receivings.rv_date) = 2013)) AS 'in@10',
    (SELECT 
            sum(invoice_items.quantity)
        FROM
            invoice_items,
            invoices
        WHERE
            invoice_items.invoice_id = invoices.id
                AND invoice_items.product_id = products.id
                AND (MONTH(invoices.inv_date) = 10
                AND YEAR(invoices.inv_date) = 2013)) AS 'out@10',
    (SELECT 'rem' - IFNULL('in@10', 0) + IFNULL('out@10', 0)) AS 'cur@9'
FROM
    products,
    stock
WHERE
    stock.product_id = products.id
ORDER BY products.code

That’s it.