select t2.eid, t2.ename, t2.yearmonth
from D t2
join
(
select t1.eid, max(t1.yearmonth) as yearmonth
from D t1
group by t1.eid
) t3
on t2.eid = t3.eid and t2.yearmonth = t3.yearmonth
运行通过后请采纳,谢谢!
你好!
你写的确实有点复杂!
你可以分两步:
1 . 获取每个人每个学科的最新考试成绩
select b.name,b.class,b.score from score b,(select a.name,a.class,max(a.time) tims from score a group by a.name,a.class) a
where b.name = a.name
and a.class = b.class
and a.tims = b.time
2 . 进行行专列 *** 作
对上面的数据进行行列转化 *** 作,比较常见了!
欢迎追问,望采纳
先排序 再 用 group by 取假设 table xxx
select * from
(select * from xxx order by time desc ) a
group by type
order by type
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)