SQL practice questions and classic questions

https://blog.csdn.net/mrbcy/article/details/68965271

 

classic example

19. Query the records of all students whose grades in the elective "3-105" course are higher than those of the "109" student.

SELECT s1.Sno,s1.Degree
FROM Scores AS s1 INNER JOIN Scores AS s2
ON(s1.Cno=s2.Cno AND s1.Degree>s2.Degree)
WHERE s1.Cno='3-105' AND s2.Sno='109'
ORDER BY s1.Sno;

12. Look up the average scores of courses starting with 3 that have at least 5 students taking courses in the Score table.

SELECT Cno,AVG(Degree)
FROM Scores
WHERE Cno LIKE '3%'
GROUP BY Cno
HAVING COUNT(Sno) >= 5;


10. Query the student number and course number with the highest score in the Score table.

SELECT Sno,Cno
FROM Scores
ORDER BY Degree DESC
LIMIT 1;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324574624&siteId=291194637