use StudentManageDB
go
select StudentName,StudentAddress from Students
where StudentAddress like '天津%' select StudentName,StudentAddress from Students
where StudentName like '%小%' select * from ScoreList
where CSharp between 80 and 90 select StudentName,StudentAddress,Birthday from Students
where Birthday between '1987-01-01' and '1988-01-01' select StudentName,StudentAddress,age from Students
where Age in(21,22,23) select StudentName,StudentAddress,age from Students
where StudentName in('王小虎','贺小张') select SUM(CSharp) as C#总成绩 from ScoreList select 总人数=COUNT(*) from Students select MAX(Csharp) as C#最高分 ,MIN(CSharp) as C#最低分,AVG(CSharp) as C#最低分 from ScoreList select Students.StudentId,C#成绩=CSharp,StudentName,ClassName
from ScoreList
inner join Students on Students.StudentId=ScoreList.StudentId
inner join StudentClass on Students.ClassId=StudentClass.ClassId
where CSharp >80 select Students.StudentId,StudentName,Gender ,C#成绩=CSharp from Students
left outer join ScoreList on Students.StudentId=ScoreList.StudentId
where Gender='男' select Students.StudentId,StudentName,Gender ,C#成绩=CSharp from ScoreList
left outer join Students on Students.StudentId=ScoreList.StudentId
where Gender='男' select 班级=StudentClass.ClassName,人数=COUNT(*),C#最高分=Max(CSharp),DB最高分=MAX(SQLServerDB),
AVG(CSharp) as C#平均分,AVG(SQLServerDB) as DB平均分
from Students
inner Join StudentClass on Students.ClassId =StudentClass.ClassId
inner join ScoreList on ScoreList.StudentId=Students.StudentId
group by ClassName
having AVG(CSharp)>=70 and AVG(SQLServerDB)>=70 select * from ScoreList
select StudentId from ScoreList group by StudentId having COUNT(*)>1 select * from ScoreList
where StudentId in(select StudentId from ScoreList group by StudentId having COUNT(*)>1)
order by StudentId select * from ScoreList
where (select COUNT(*) from ScoreList s where s.StudentId=ScoreList.StudentId)>1
order by StudentId

sqlserver 模糊查询,连表,聚合函数,分组的更多相关文章

  1. ef实现一次查询多个聚合函数的字段

    想用ef来写一个统计字段的语句,如下所示 select sum(price) as price_total, sum(amount) as amount_total from table1 发现似乎实 ...

  2. 18 12 06 sql 的 基本语句 查询 条件查询 逻辑运算符 模糊查询 范围查询 排序 聚合函数 分组 分页 连接查询 自关联 子查询

    -- 数据的准备 -- 创建一个数据库 create database python_test charset=utf8; -- 使用一个数据库 use python_test; -- 显示使用的当前 ...

  3. mysql 数据操作 单表查询 group by 聚合函数

    强调: 如果我们用unique的字段作为分组的依据,则每一条记录自成一组,这种分组没有意义 多条记录之间的某个字段值相同,该字段通常用来作为分组的依据 如果按照每个字段都是唯一的进行分组,意味着按照这 ...

  4. mysql 数据操作 单表查询 group by 聚合函数 没有group by情况下

    聚合函数只能用在组里使用 #没有group by 则默认算作一组 取出所有员工的最高工资 mysql> select max(salary) from employee; +---------- ...

  5. sqlserver模糊查询【转】

    http://blog.csdn.net/liuxinxin1125/article/details/5444873 SELECT * FROM user WHERE name LIKE ';%三%' ...

  6. Django模型层之字段查询参数及聚合函数

    该系列教程系个人原创,并完整发布在个人官网刘江的博客和教程 所有转载本文者,需在顶部显著位置注明原作者及www.liujiangblog.com官网地址. 字段查询是指如何指定SQL WHERE子句的 ...

  7. django字段查询参数及聚合函数

    字段查询是指如何指定SQL WHERE子句的内容.它们用作QuerySet的filter(), exclude()和get()方法的关键字参数. 默认查找类型为exact. 下表列出了所有的字段查询参 ...

  8. MySQL☞聚合函数/分组函数

    分组函数(聚合函数) 1.count(*/列名): a.*:求出该数据的总条数 select  count(*)  from 表名 b.列名:求出该列中列名不为null的总条数 select  cou ...

  9. mysql关联模糊查询他表字段

    如下:订单表关联了用户的id(多个),要根据用户名模糊查询订单信息,但是订单表只有id.创建视图用不着,咱也没权限.于是如下 SELECT * FROM ( SELECT cu.id AS 'id', ...

随机推荐

  1. LG2516 【[HAOI2010]最长公共子序列】

    前言 感觉这几篇仅有的题解都没说清楚,并且有些还是错的,我再发一篇吧. 分析 首先lcs(最长公共子序列)肯定是板子.但这题要求我们不能光记lcs是怎么打的,因为没这部分分,并且另外一个方程的转移要用 ...

  2. Java基础二(变量、运算符)

    1.变量2.运算符 ###01变量概述 * A: 什么是变量? * a: 变量是一个内存中的小盒子(小容器),容器是什么?生活中也有很多容器,例如水杯是容器,用来装载水:你家里的大衣柜是容器,用来装载 ...

  3. DevExpress控件使用方法:第一篇 gridControl详解

    GridControl (1)层次设计器 有五种视图模式,banded gridview多行表头,数据还是一行一组,最靠近数据的表头与数据一一对应:advanced banded gridview多行 ...

  4. vi常用操作

    什么是vi: vi是Linux/Unix底下最常用的文本编辑器,可以理解为和Windows下的txt一样,咱们一般操作linux服务器的时候都是没有图形化界面的, 怎么移动光标,到哪个位置,替换修改什 ...

  5. Morris

    Morris /*Morris遍历树: *一:如果一个结点有左子树会到达此节点两次(第二次到达结点的时候左子树的所有结点都遍历完成),第一次遍历左子树最后 * 节点为nullptr,第二次遍历指向他自 ...

  6. [转]Intellij IDEA快捷键

    [常规]Ctrl+Shift + Enter:语句完成“!”:否定完成:输入表达式时按 “!”键Ctrl+E:最近的文件Ctrl+Shift+E:最近更改的文件Shift+Click:可以关闭文件Ct ...

  7. 使用.pth文件扩展python环境路径

    使用.pth文件扩展python环境路径 有时候我们不希望把一个库放到 site-packages 下面,而是更愿意把它保留在原始的工程目录中,方便管理和维护.那么怎么能让 Python 运行环境找到 ...

  8. OpenCV几种访问cv::Mat数据的方法

    一般来说,如果是遍历数据的话用指针ptr比用at要快.特别是在debug版本下.因为debug中,OpenCV会对at中的坐标检查是否有溢出,这是非常耗时的. 代码如下 #include <op ...

  9. java Collections.sort()

    sort()是Collections中的静态方法,用于对List容器中的元素排序. 如容器list中存储的是Integer对象 List<Integer> list =Arrays.asL ...

  10. 非GUI模式

    先启动jmeter的图形界面. 在自动时可以看到控制台输出的信息. 1.提示不用使用GUI进行负载测试. 2.命令行格式.   打开之前保存的百度的测试脚本.   线程数调为100,循环次数是2. R ...