I can do this with regular mySQL but I would like to be able to do it "the magento way" as it were...
What I would like to do, is run a query which will SUM(grand_total) for my order totals between set dates, ie work out the total revenue from July 2012.
I've tried various variations on this, and I might be really close or I might be a million miles away, so I'd appreciate any help anyone can give me! What I have so far is:
$orders = Mage::getModel('sales/order')->getCollection();
$orders->addAttributeToFilter('date_field', array(
'from' => '2011-09-01',
'to' => '2011-09-30',
));
$orders->addExpressionAttributeToSelect('grand_total', 'SUM({{grand_total}})', grand_total);
$orders_total->getSelect()->$orders->grand_total(SUM(grand_total));
Thank you in advance!