sql_纵表变横表
method | certificate | value | ||
getUserId | 123 | getUserid | ||
startTime | 123 | 22 | ||
endTime | 123 | 33 | ||
如表所示,现在有一个需求,要算getUserId的执行时间,给一个思路,先查询出method=getUserID,和certificate,作为一个结果集,再查出来method=startTime的结果集,然后重新
select from这三个结果集r1,r2,r3,
where R1.CERTIFICATE=R2.CERTIFICATE
AND r1.certificate = r3.certificate即可