【问题标题】:MYSQL: Select records based on the time intervalsMYSQL:根据时间间隔选择记录
【发布时间】:2014-02-15 05:09:52
【问题描述】:

我有一个表,其中包含带有日期时间列的记录。记录将每 3/5/8(动态)秒插入到该表中。

需要:我每天只需要显示一条记录。这里我有一个条件是记录应该在上午 10 点到 11 点之间插入。

所以我喜欢在 where 子句中使用该条件并使用 max 来获取记录。但我不能。 请指教。

【问题讨论】:

  • @suresh: select *, max(datetime_column) from table where 1 group by date(datetime_column).

标签: mysql


【解决方案1】:

试试下面的方法:

select * from tblName where HOUR(datetime_column) between 10 AND 11 group by DAY(datetime_column)

【讨论】:

    猜你喜欢
    • 2014-09-12
    • 2013-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-06
    • 1970-01-01
    相关资源
    最近更新 更多