gpt4 book ai didi

MYSQL 绑定(bind)最大值

转载 作者:行者123 更新时间:2023-11-29 03:41:13 25 4
gpt4 key购买 nike

您好,我有一张表格,其中列出了西类牙语类(class)的开始和结束时间以及日期和老师。我正在尝试编写一个 MYSQL 查询,列出每个老师上课最多的日期,即他们最忙的那一天。如果有几天可以打领带,我想同时展示两者。

这是我目前所拥有的,但它只返回一个日期,即使有平局,我觉得这是因为我在最后对老师进行了分组

SELECT teacher_no, date
FROM (
SELECT COUNT(date)AS counted,teacher_no,date
FROM Spanish
GROUP BY teacher_no,date
) AS t
GROUP BY teacher_no

最佳答案

试试这个:

SELECT  teacher_no, date, COUNT(date) AS counted
FROM Spanish s
GROUP BY teacher_no, date
HAVING COUNT(date) = (SELECT COUNT(date) AS counted
FROM Spanish
WHERE teacher_no = s.teacher_no
GROUP BY teacher_no, date
ORDER BY counted DESC
LIMIT 1
);

关于MYSQL 绑定(bind)最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13591794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com