时间:2021-07-01 10:21:17 帮助过:28人阅读
在mysql下的sql:由于mysql没有rownum所以用了它的替代
1 SELECT cc.team TEAM, MIN(cc.y) BEGIN,MAX(cc.y)+1 END FROM 2 (SELECT aa.team ,aa.y , @rownum:=@rownum+1 AS rownum FROM 3 (SELECT @rownum:=0) r , 4 (SELECT team ,Y FROM `nba` ORDER BY Y) aa , 5 (SELECT team ,Y FROM NBA ORDER BY Y) bb 6 WHERE aa.team = bb.team AND aa.y=bb.y-1) cc 7 GROUP BY (cc.y-cc.rownum) 8 ORDER BY MIN(cc.y)
结果:
sql笔试题-1
标签:oracle 笔试题 and nbsp log pre sel style where