MySQL-每月最多摘要

时间:2018-06-25 17:27:45

标签: mysql

我有这个实体:

int arr = {10,20};

int *p = arr; // p points to the first element of array, i.e 10
*(p)++; // now p points to the next element i.e 20.

,我想找出最大月份(可记录的月份)。我有最高价,但是月份错了。

payments(idPayment, idGroup, price, paymentDate)

感谢建议

1 个答案:

答案 0 :(得分:1)

您可以使用public class Customer { public long Id { get; set; } public string UserName { get; set; } public AddressModel Address { get; set; } } ORDER BY来选择价格最高的行

LIMIT

SELECT SUM(price) as price, YEAR(paymensDate) as year, MONTH(paymentDate) as month FROM `payments` WHERE idGroup=27 GROUP BY YEAR(paymentDate), MONTH(paymentDate) ORDER BY price DESC LIMIT 1 将提供所提供列的最大值,但不能保证该列的其他值会返回该行中由max选取的相同值