$results = DB::select( DB::raw("SELECT products.title, products.price, x.sales
FROM products
INNER JOIN
(
SELECT product_id,
MAX(sales) AS sales
FROM offers
GROUP BY product_id
) x
ON x.product_id = products.id
ORDER BY x.sales DESC LIMIT 20") );
set_time_limit(600);
Artisan::call('youtrack:sync', [], $buffer);