Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好的,所以我有一个用户表和一个付款表。每笔付款都有一个 date_paid 和 amount_paid。我想按支付金额的总和对付款进行分组,但我还想为最后一个 date_paid 保留一个字段。这可能吗?或者我是否必须在用户表中存储一个 last_date_paid 列?
SELECT id, SUM(amount_paid), MAX(date_paid) FROM payments GROUP BY id