SQL第十章

来源:互联网 发布:网络成瘾的心理成因 编辑:程序博客网 时间:2024/06/05 04:24
--查询住址'山东'  SELECT StudentName,Phone,Address FROM Student WHERE Address LIKE '%山东%'  --查询出生日期  SELECT * FROM Student WHERE BornDate BETWEEN '1989-1-1' AND '1995-12-31'  上机练习2  --统计数据库中学生总人数  SELECT COUNT (*) AS 学生总人数 FROM Student  --查询第一学期的总学时  SELECT SUM (ClassHour) As 第一学期的总学时 FROM Subject WHERE GradeId=1  --考试总成绩  SELECT SUM (StudentResult) As 第一学期的总成绩 FROM Result, [MySchool].[dbo].[Student] WHERE student.StudentNo='S1101004' AND GradeId IN (1,2,3,4)  --考试平均分  SELECT AVG (StudentResult) As S1101004的第一学期平均分 FROM Result,[MySchool].[dbo].[Student] WHERE student.StudentNo='S1101004' AND GradeId IN (1,2,3,4)  --最高分 最低分 平均分  SELECT MAX (StudentResult) As 最高分,MIN(StudentResult) AS 最低分,AVG(StudentResult) AS 平均分 FROM Result WHERE SubjectId=3 AND ExamDate='2013-3-22'  --及格学生的平均分  SELECT AVG (StudentResult) As 及格学生的平均分 FROM Result WHERE SubjectId=3 AND  ExamDate='2013-3-22' AND StudentResult>=60  --考试科目学生的平均分  SELECT AVG (StudentResult) As C#语言课数据库技术 FROM Result WHERE SubjectId=3
 --查询学号  SELECT * FROM Result WHERE StudentNo='S1101004' AND SubjectId IN (1,2,3)

--查询电话  SELECT StudentName,Phone,Address FROM Student WHERE Phone LIKE '1387%'  --查询姓'姜'  SELECT StudentNo,StudentName,Address FROM Student WHERE StudentName LIKE '姜_'


0 0