本文介绍了按连接表最大值选择仅行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想为u.classno,u.userno选择最大b.enddate的行.但这不起作用.
I want to select only the row which has max b.enddate for u.classno, u.userno. But it doesn't work.
select u.classno, u.userno, b.enddate
from libUser u
join book b on b.id = u.bookid
group by u.classno, u.userno
having b.enddate=max(b.enddate) //doesn't works
推荐答案
怎么了?
select u.classno, u.userno, MAX(b.enddate)
from libUser u
join book b on b.id = u.bookid
group by u.classno, u.userno
这篇关于按连接表最大值选择仅行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!