如何获得整行及其数据的 MAX(total)? MySQL
How can I get the MAX(total) with the whole row and its data? MySQL
我有 table 账单有一些列,例如(订单号、日期和总计)我想获得特定日期的 MAX(总计)整行及其数据。
这是 table:
Click here to show the picture
我已经在 MySQL 中写了一些行,但出现了一些错误
SELECT * FROM biling WHERE total=(SELECT MAX(total) FROM biling WHERE date='2021-10-26')
假设此查询的第二部分等于 50
它确实带有最大计费但是如果这一天有超过一行的 MAX(total) 相同我只想只计算一行。
我希望你们明白我的意思。提前致谢。
将 LIMIT 1
添加到 select 的末尾似乎是解决方案。
更新!
所需的简单解决方案是
SELECT * FROM biling WHERE date='2021-10-26' ORDER BY total DESC LIMIT 1
我有 table 账单有一些列,例如(订单号、日期和总计)我想获得特定日期的 MAX(总计)整行及其数据。
这是 table: Click here to show the picture
我已经在 MySQL 中写了一些行,但出现了一些错误
SELECT * FROM biling WHERE total=(SELECT MAX(total) FROM biling WHERE date='2021-10-26')
假设此查询的第二部分等于 50
它确实带有最大计费但是如果这一天有超过一行的 MAX(total) 相同我只想只计算一行。
我希望你们明白我的意思。提前致谢。
将 LIMIT 1
添加到 select 的末尾似乎是解决方案。
更新!
所需的简单解决方案是
SELECT * FROM biling WHERE date='2021-10-26' ORDER BY total DESC LIMIT 1