搜尋

首頁  >  問答  >  主體

如何從結果集中僅顯示最低值(MYSQL)

我有以下聲明:

select DATE(recieved_on) as Day, round (count(*) / 24)  AS 'average'
from message
where facility in ('FACID')
AND received on BETWEEN '2022-05-29 00:00:00' AND '2022-06-04 23:59:59'
GROUP BY DATE(received on);

它提供了以下結果集:

平均
日期
日期
日期
日期
日期
日期
日期

如何只顯示結果集中的最低值而不是全部 7 個值?

P粉338969567P粉338969567228 天前757

全部回覆(1)我來回復

  • P粉790819727

    P粉7908197272024-04-07 16:45:30

    您只需使用 order by 和 limit 即可:

    select DATE(recieved_on) as Day, round (count(*) / 24) AS 'average'
    from message
    where facility in ('FACID') AND received on BETWEEN '2022-05-29 00:00:00' AND '2022-06-04 23:59:59'
    GROUP BY DATE(received on)
    order by average
    limit 1

    回覆
    0
  • 取消回覆