是要这个结果不 select ActionType,AgentID from 表名 where id=(select max(id) from 表名) 或者是这个: select ActionType,AgentID from 表名 where id in (select max(id) from 表名 group by agentID)
回音无痕(提问者)
select b.* from (
select max(id) id,agentid from agent_state
where date_format(actiontime, \'%Y-%m-%d\')=date_format(now(), \'%Y-%m-%d\')
group by agentid)a left join agent_state b
on a.id=b.id,改动下
回音无痕(提问者) 回复 孤陌警告:com.fr.general.data.TableDataException: 错误代码:1301 数据集配置错误
Query:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'table
where ActionType=a.ActionType
and ActionTime
孤陌 回复 回音无痕(提问者)select a. * from tb a where val = ( select max (val) from tb where name = a.name) order by a.name 这样写 你不是就是想要 拿到ActionType字段分组后 的ID最大值吗?