"SELECT store.name,SUM(data.total) as summ,data.storeID from store, data WHERE store.storeID = data.storeID and MONTH(`date`) = MONTH(DATE_ADD(NOW(), INTERVAL -1 MONTH)) and YEAR(`date`) = YEAR(DATE_ADD(NOW(), INTERVAL -1 MONTH)) group by storeID order by summ DESC";
array {
[name] => name
[summ] => 1 Первый период
[summ2]=> 2 Второй период
}