【发布时间】:2022-01-11 07:20:18
【问题描述】:
我希望为表 2 中的每个班级-教师对在表 1 中随机抽取 2 个学生姓名。我研究过使用
表 1
| Class | Teacher |
|---|---|
| Math | Mr. Smith |
| Math | Mrs. Kim |
| Science | Mr. Smith |
| Science | Mrs. Kim |
表 2
| Student |
|---|
| Matt |
| Jess |
| Tom |
| Sally |
| Rod |
| Nikki |
最后的例子
| Class | Teacher | Student |
|---|---|---|
| Math | Mr. Smith | Matt |
| Math | Mr. Smith | Sally |
| Math | Mrs. Kim | Nikki |
| Math | Mrs. Kim | Rod |
| Science | Mr. Smith | Matt |
| Science | Mr. Smith | Jess |
| Science | Mrs. Kim | Tom |
| Science | Mrs. Kim | Rod |
【问题讨论】:
-
您真的需要它们是随机的,还是只有任何个学生会这样做?
-
它们必须是随机的
标签: sql database postgresql