相关代码 |
|
DECLARE @myavg float SELECT @myavg=AVG(writtenExam) from stuMarks print '本班平均分'+convert(varchar(5),@myavg) IF (@myavg>70) BEGIN print '本班笔试成绩优秀,前三名的成绩为' SELECT TOP 3 * FROM stuMarks ORDER BY writtenExam DESC END ELSE BEGIN print '本班笔试成绩较差,后三名的成绩为' SELECT TOP 3 * FROM stuMarks ORDER BY writtenExam DESC END