zoukankan      html  css  js  c++  java
  • sql如何分组选择显示最新的一条数据

    怎样在数据库的一个表里筛选出每一人的时间最新的一条记录?用SQL语句

    -- 方法1
    select a.*
    from table1 a
    where not exists(select 1
    from table1 b
    where b.name=a.name and b.gdtime>a.gdtime)

    -- 方法2
    select a.*
    from table1 a
    inner join
    (select name,
    max(gdtime) 'maxgdtime'
    from table1
    group by name) b on a.name=b.name and a.gdtime=b.maxgdtime

  • 相关阅读:
    css 图片的无缝滚动
    有时间研究下这个
    js的类数组对象
    js的this什么时候会出现报错
    js前端分页
    js队列
    js前端处理url中的参数为对象
    随机看的一点代码
    js的callee和caller方法
    js的Object和Function
  • 原文地址:https://www.cnblogs.com/zxtceq/p/7976567.html
Copyright © 2011-2022 走看看