select student.* from student join((select cid,max(score) max from scores group by cid) t1 join scores t2 where t1.cid=t2.cid) t3 where t3.sid=student.sid
时间: 2023-04-10 13:04:50 浏览: 67
这是一个 SQL 查询语句,目的是查询每个课程中得分最高的学生信息。具体实现方式是通过子查询找到每个课程的最高分数,然后再通过 join 操作将该课程的最高分数与学生表中的信息进行关联,最终得到每个课程中得分最高的学生信息。
相关问题
SELECT * FROM comment where scores=5 ORDER BY create_time DESC LIMIT 1;
你的 SQL 语句看起来是正确的,假设你的表名是 `comment`,你想要查询 `scores` 字段等于 `5` 的最新一条评论记录,按照 `create_time` 字段进行倒序排序,可以使用上述 SQL 语句。
需要注意的是,这条 SQL 语句只会返回 `scores` 字段等于 `5` 的最新一条评论记录。如果你想要查询其他条件下的最新记录,可以根据实际情况更改 `WHERE` 子句中的条件。
SELECT * FROM t_student HAVING SUM(math + chinese + english) > 240;
As an AI language model, I cannot access the database to execute this query. However, I can explain the query.
This query selects all columns from the table t_student where the sum of the math, chinese, and english scores is greater than 240. The HAVING clause is used to filter the rows based on the result of an aggregate function, in this case, the SUM function.
相关推荐
![csv](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)