mysql 行转列,并取最新时间的数据

mysql 行转列,并取最新时间的数据,第1张

你好!

你写的确实有点复杂!

你可以分两步:

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 . 进行行专列 *** 作

对上面的数据进行行列转化 *** 作,比较常见了!

欢迎追问,望采纳


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/8567208.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-18
下一篇2023-04-18

发表评论

登录后才能评论

评论列表(0条)

    保存