1 use StudentManageDB 2 go 3 select Studentname,StudentAddress from Students 4 where StudentAddress like ‘天津%‘ 5 6 select Studentname,StudentAddress from Students 7 where Studentname like ‘%小%‘ 8 9 select * from scoreList10 where CSharp between 80 and 9011 12 select Studentname,StudentAddress,Birthday from Students13 where Birthday between ‘1987-01-01‘ and ‘1988-01-01‘14 15 select Studentname,age from Students16 where Age in(21,22,23)17 18 select Studentname,age from Students19 where Studentname in(‘王小虎‘,‘贺小张‘)20 21 22 select SUM(CSharp) as C#总成绩 from scoreList23 24 select 总人数=COUNT(*) from Students 25 26 select MAX(Csharp) as C#最高分,MIN(CSharp) as C#最低分,AVG(CSharp) as C#最低分 from scoreList27 28 select Students.StudentID,C#成绩=CSharp,Studentname,Classname29 from scoreList30 inner join Students on Students.StudentID=scoreList.StudentID31 inner join StudentClass on Students.ClassID=StudentClass.ClassID32 where CSharp >8033 34 select Students.StudentID,Gender,C#成绩=CSharp from Students35 left outer join scoreList on Students.StudentID=scoreList.StudentID36 where Gender=‘男‘37 38 select Students.StudentID,C#成绩=CSharp from scoreList39 left outer join Students on Students.StudentID=scoreList.StudentID40 where Gender=‘男‘41 42 select 班级=StudentClass.Classname,人数=COUNT(*),C#最高分=Max(CSharp),DB最高分=MAX(sqlServerDB),43 AVG(CSharp) as C#平均分,AVG(sqlServerDB) as DB平均分44 from Students45 inner Join StudentClass on Students.ClassID =StudentClass.ClassID46 inner join scoreList on scoreList.StudentID=Students.StudentID47 group by Classname48 having AVG(CSharp)>=70 and AVG(sqlServerDB)>=7049 50 select * from scoreList51 select StudentID from scoreList group by StudentID having COUNT(*)>152 53 select * from scoreList54 where StudentID in(select StudentID from scoreList group by StudentID having COUNT(*)>1)55 order by StudentID56 57 select * from scoreList58 where (select COUNT(*) from scoreList s where s.StudentID=scoreList.StudentID)>159 order by StudentID总结
以上是内存溢出为你收集整理的sqlserver 模糊查询,连表,聚合函数,分组全部内容,希望文章能够帮你解决sqlserver 模糊查询,连表,聚合函数,分组所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)