mysql查询(分组依据?独特的?)

bq9c1y66  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(349)

这个问题在这里已经有答案了

mysql仅从最新日期选择不同的记录(2个答案)
两年前关门了。
表行

no | f_member_id | f_teacher_id | f_class_date
 1 | jenny       | teacher_a    | 2017-12-03
 3 | jenny       | teacher_a    | 2017-12-05
 2 | jenny       | teacher_a    | 2017-12-04
 4 | tom         | teacher_a    | 2017-11-27
 5 | tom         | teacher_a    | 2017-11-28

“a老师”需要看到这样的结果。

---------------
jenny | teacher_a | 2017-12-05
tom   | teacher_a | 2017-11-28

------

***老师所在班级的学生姓名的最近上课日期。

我这样问。不起作用。

SELECT distinct(f_member_id), f_class_date 
 FROM `classroom` where f_teacher_id='teacher' 
 group by f_member_id 
 order by f_class_date desc
vngu2lb8

vngu2lb81#

select f_member_id, f_teacher_id ,max(f_class_date) from table group by f_member_id,f_teacher_id;

相关问题