一道sql题引发的关于where、having、group by

2019-04-22  本文已影响0人  c747190cc2f5

上原题:

我的语句:

CREATE TRIGGER t on SC FOR INSERT AS  DELETE FROM SC WHERE EXISTS(
SELECT * FROM inserted WHERE sno = SC.sno and cno = Sc.cno
AND sno IN (SELECT sno  FROM SC WHERE grade <60) 
AND sno IN (SELECT sno FROM SC WHERE cno IN (SELECT cno FROM Course WHERE Credit > 4) GROUP BY sno HAVING count(*) > 4)
AND sno not IN (SELECT top(0.1*(SELECT count(*) FROM Stu)  sno FROM SC GROUP BY sno ORDER BY AVG(Grade) DESC)
)

总结反思:

上一篇 下一篇

猜你喜欢

热点阅读