【发布时间】:2019-05-16 15:56:58
【问题描述】:
首先,我遇到了计算每天销售的产品的问题。在sql中我有查询
select product_name, sum(quantity) as quantity from invoice_product
join invoices on invoices.id = invoice_product.invoice_id
join products on products.id = invoice_product.product_id
where invoices.issued_at = '2019-05-16'
and products.`made_by_us` = 1
group by product_name
它向我展示了有趣的信息,但我使用 product_name 来制作 group by 但我应该使用 product_id - 我也需要显示名称,但我不知道该怎么做。
其次,我想在 Laravel 中使用它,所以也许有人知道在 Eloquent 中可以使用它吗?
提前谢谢你:)
【问题讨论】: