随机抽取的sql语句 每班任意抽取3名学生
作者:whsnow 时间:2024-01-27 10:12:26
学校有一、二、三。。。。至十班。
假设每个班上有30名学生。张、李、刘、苏等
现有这样的表 student ,字段 class 及name 。其中class 表示班级,name 表示每班学生姓名。
要求每班任意抽取3名学生出来,进行学校大扫除。
请写出这样的SQL语句。
select name
from (select (row_number() over (partition by class order by checksum(newid()))) id,*
from student ) a
where id<=3
标签:随机抽取
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
利用Python2下载单张图片与爬取网页图片实例代码
2023-06-25 00:57:22
![](https://img.aspxhome.com/file/2023/4/81494_0s.jpg)
python爬虫系列Selenium定向爬取虎扑篮球图片详解
2021-02-19 17:21:52
![](https://img.aspxhome.com/file/2023/4/133244_0s.jpg)
Pycharm使用远程linux服务器conda/python环境在本地运行的方法(图解))
2021-05-13 07:42:11
![](https://img.aspxhome.com/file/2023/8/105298_0s.jpg)
python模块hashlib(加密服务)知识点讲解
2022-11-30 20:38:20
使用keras实现densenet和Xception的模型融合
2022-04-15 19:17:01
![](https://img.aspxhome.com/file/2023/1/77901_0s.jpg)
Oracle 创建监控账户 提高工作效率
2009-10-14 11:47:00
![](https://img.aspxhome.com/file/UploadPic/200910/14/20091014121213816.jpg)
Go实现简易RPC框架的方法步骤
2024-04-26 17:16:33
python递归全排列实现方法
2021-11-17 15:16:04
JQuery中对Select的option项的添加、删除、取值
2024-04-22 12:59:14
用python实现k近邻算法的示例代码
2022-08-28 16:08:58
opencv resize图片为正方形尺寸的实现方法
2023-02-21 15:34:51
![](https://img.aspxhome.com/file/2023/0/92410_0s.jpg)
Pandas对DataFrame单列/多列进行运算(map, apply, transform, agg)
2022-10-10 19:11:55
PHP根据key删除数组中指定的元素
2023-07-17 19:46:27
Python批量修改xml的坐标值全部转为整数的实例代码
2021-10-29 00:57:50
![](https://img.aspxhome.com/file/2023/8/65548_0s.jpg)
python实现飞机大战游戏(pygame版)
2021-11-11 17:59:24
![](https://img.aspxhome.com/file/2023/9/97109_0s.gif)
Linux 中PHP的安装教程
2023-10-07 20:34:21
2021年最新版Python安装及使用教学
2022-09-18 08:24:00
![](https://img.aspxhome.com/file/2023/9/135359_0s.png)
SQL Server中的文件和文件组介绍
2024-01-14 06:57:45
![](https://img.aspxhome.com/file/2023/3/88243_0s.jpg)
如何正确显示模式对话框showModalDialog中的中文?
2010-06-28 18:24:00
python实现BackPropagation算法
2022-03-26 12:06:39