DECLARE @MyNO CHAR(8) SET @MyNO="20030001" IF (SELECT專業(yè) FROM Students WHERE 學號=@MyNO)="計算機軟件" BEGIN SELECT AVG(成績) AS 平均成績 FROM Score WHERE學號=@MyNO END ELSE PRINT "學號為" +@MyNO+"的學生不存在或不屬于軟件專業(yè)" GO