我应该如何在laravel中执行此sql查询?我从一开始就遇到了困难

时间:2018-02-11 01:55:27

标签: laravel laravel-5.5

我应该如何在laravel中执行此sql查询?我从一开始就遇到了问题。

select buy.buyer,buy.buysum,sale.seller,sale.salesum,buy.buysum + sale.salesum as "Total" from
(select buyer,sum(amount) as "buysum" from tbl
group by buyer) buy
inner join
(select seller,sum(amount) as "salesum" from tbl
group by buyer) sale 
on buy.buyer=sale.seller
order by total DESC
limit 5

0 个答案:

没有答案