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. 通信协议演进与JCE协议详解

    一.通信协议概述通信协议是两个节点之间为了协同工作.实现信息交换,而协商的规则和约定,例如规定字节序,各个字段类型,使用什么压缩算法或加密算法等. 1.原始数据假设A和B通信,获取或设置用户基本资料, ...

  2. 自制操作系统Antz -- 系列文章

    自制操作系统Antz day10——实现shell(上) AntzUhl 2018-10-10 16:25 阅读:192 评论:0   Linux内核源码分析 day01——内存寻址 AntzUhl ...

  3. 枚举 Java Enumeration接口

    Enumation 定义了一些方法,通过这些方法可以枚举对象集合中的元素 如: boolean hasMoreElements() 测试此枚举是否包含更多的元素 object nextElement( ...

  4. docker 的前台模式和后台模式

    Detached(后台模式) vs foreground(前台模式) 当我们启动一个容器时,首先需要确定这个容器是运行在前台还是运行在后台. -d, --detach Run container in ...

  5. spark集群使用hanlp进行分布式分词操作说明

    本篇分享一个使用hanlp分词的操作小案例,即在spark集群中使用hanlp完成分布式分词的操作,文章整理自[qq_33872191]的博客,感谢分享!以下为全文:   分两步: 第一步:实现han ...

  6. RHEL 6.5系统安装配置图解教程(rhel-server-6.5)

    转自:http://www.jb51.NET/os/128752.html 说明: 截止目前RHEL 6.x最新版本为RHEL 6.5,下面介绍RHEL 6.5的具体安装配置过程 服务器相关设置如下: ...

  7. php限制文件下载速度的代码

    有时候你会出于某种目的而要求把下载文件的速度放慢一些,例如你想实现文件下载进度条功能.限制下载速度最大的好处是节省带宽,避免瞬时流量过大而造成网络堵塞.本文将和你分享如何通过php代码来实现限制文件的 ...

  8. ML: 降维算法-LDA

    判别分析(discriminant analysis)是一种分类技术.它通过一个已知类别的“训练样本”来建立判别准则,并通过预测变量来为未知类别的数据进行分类.判别分析的方法大体上有三类,即Fishe ...

  9. 【java】浅谈while 和do-while

    while语法格式:while(布尔表达式){//语句}先判断布尔表达式,如果为true就会执行循环体中的语句,然后再判断布尔表达式,一直到布尔表达式为false,然后循环结束.通常用算术运算符(++ ...

  10. Console下Pause效果的函数

    function PauseConsole(Prompt: PAnsiChar): boolean;var  hStdIn, hStdOut: THandle;  dwRd, dwWr, i: Car ...