我有一些数据库表:
Transaction detail_transaction product
2 (id_sale) 1 (id_detail) 3 (id_product)
Yes (status_paidOff) 2 (id_sale) fish rolls (product_name)
2020-05-28(transaction_date) 3 (id_product)
Product (sale_type) 7 (total_sale)
所以输出就像:
Product Name
Total Sale
Fish rolls 7
我要在detail_transaction
中选择一个具有 MAX total_sale
的行,条件是:
MONTH(transaction_date)=5
)Product
有人可以帮我吗?
答案 0 :(得分:0)
如果您只想让detail_transaction
的第一行满足条件,则可以将detail_transaction
与transaction
连接起来,使用where
子句进行过滤,然后使用{{1 }}和order by
:
limit