duanhuau567787 2013-06-14 10:39
浏览 11
已采纳

从DB中选择DISTINCT近期值[复制]

I need to get all distinct value from db according to their recent/last entryModTime.

For your understanding

id entry_modtime

3  13-12-1977
3  14-12-1977
4  13-12-1977
5  13-12-1977 
2  13-12-1977
3  15-12-1977

In the above table id field is not primary. I need get all data from that table so the output should be,

3 15-12-1977
4 13-12-1977
5 13-12-1977
2 13-12-1977
</div>
  • 写回答

2条回答 默认 最新

  • dongwei3866 2013-06-14 10:40
    关注

    You can group around your id and select the highest date for every id with max()

    select id, max(entry_modtime) as latest_entry_modtime
    from your_table
    group by id
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理