select *  from a where id = max(id) group by id

解决方案 »

  1.   

    这个语句,运行错误:
    select *
    from historydata
    where id = max(id)
    group by CollectorNo,Port
      

  2.   

    SELECT * from Table where id=(SELECT MAX(id) FROM Table)
      

  3.   

    select *
    from historydata
    where id = (SELECT MAX(id) FROM historydata group by CollectorNo,Port)
      

  4.   

    select *
    from historydata
    where id = (SELECT MAX(id) FROM historydata group by CollectorNo,Port)
    正确