Reputation: 1366
Please any one may help me to make this query in laravel5.1:
SELECT sum(orders.price) - (select sum(orders.price)
FROM orders INNER JOIN articles ON articles.id = orders.article_id
WHERE articles.forSale = false)
FROM orders INNER JOIN articles ON articles.id = orders.article_id
e articles.forSale=true
Upvotes: 0
Views: 78
Reputation: 1366
I got it :
$query = "select (sum(orders.price) -
(select sum(orders.price) from orders
inner join articles on articles.id = orders.article_id
where articles.forSale = false)
) as p1 from orders
inner join articles on articles.id = orders.article_id
where articles.forSale = true";
return \DB::select($query);
Upvotes: 1