select
t3.user_id,
t4.city_id,
(t3.oper_zayavki / t4.`Заявки`) * t4.`Расход`
from Goroda_Statistika t4
inner join
(
select
t1.user_id,
t2.city_id,
sum(t2.`Заявки`) as oper_zayavki
from Operatory t1
join Operatory_Statistika t2 on t2.user_id = t1.user_id
group by t1.user_id, t2.city_id
) t3 on t3.city_id = t4.city_id
<?php
require '/vendor/autoload.php';
use Illuminate\Support\Collection;
$array = array(
array('id' => '7', 'name' => 'foo'),
array('id' => '7', 'name' => 'foo2'),
array('id' => 10, 'name' => 'bar'),
array('id' => 10, 'name' => 'bar2'),
array('id' => 11, 'name' => 'bar3')
);
$collection = new Collection($array);
$grouped = $collection->groupBy('id');
$grouped->each(function ($item, $key) {
print_r($key . PHP_EOL);
print_r($item);
});
AND addresses.id_address NOT IN (
SELECT id_address FROM clients_addresses WHERE id_address = addresses.id_address
)
AND clients_addresses.id_address IS NULL
SELECT
a.*,
accounts.id_account,
accounts.name as name_account,
clients_addresses.id_client as on_client,
clients.name
FROM
(SELECT
*
FROM addresses
WHERE id_project = 10
AND id_account = 65
) a
LEFT JOIN ....
public function getCategoryNames($product_id) {
$query = $this->db->query("SELECT *, dac.top
FROM " . DB_PREFIX . "category_description cd
LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p2c.category_id = cd.category_id)
LEFT JOIN " . DB_PREFIX . "de_av_category as dac ON (p2c.category_id = dac.category_id)
WHERE p2c.product_id = '" . (int)$product_id . "'AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->rows;
}