select author,max(pid) as maxpid from users
where tid =3 group by tid;
表结构
--------------------------------------------------------
pid tid(部门id) author(用户名)
--------------------------------------------------------
1 3 张三
2 3 李四
3 3 王五
4 3 赵六
--------------------------------------------------------问题:我取出来的结果 4 张三
为什么不是4 赵六呢,请解释一下,谢谢
where tid =3 group by tid;
表结构
--------------------------------------------------------
pid tid(部门id) author(用户名)
--------------------------------------------------------
1 3 张三
2 3 李四
3 3 王五
4 3 赵六
--------------------------------------------------------问题:我取出来的结果 4 张三
为什么不是4 赵六呢,请解释一下,谢谢
(select tid,max(pid) as ma from tt group by tid) b
on a.tid=b.tid and a.pid=b.ma