MYSQL查询每个用户第一次取得证书信息

上SQL

SELECT * FROM (
SELECT va.accountId, va.name,va.fullname,vs.createtime as lastupdatetime, vs.certificate_code,vl.name as splan FROM vmb_learningactivity as vl
inner join  vmb_studyrecorde as vs on vs.learningactivityid = vl.learningActivityId
inner join vmb_account as va on va.accountId = vs.accountid
WHERE vs.collegeid =94 and vs.sucessfuled = 1 and vs.starttime >= '2019-06-18 00:00:00' 
and vs.endtime < '2020-02-01 00:00:00' 
and vs.certificate_code != ""
-- 时间从早到晚排序
GROUP BY vs.createtime asc
) as base

GROUP BY name

先对获得证书的所有证书的信息以时间进行排序,然后二次查询对名字排序。

你可能感兴趣的:(MySQL,mysql)