3 2 3 3 3 4 4 1 5 1 5 2 我需要取结果最低的学生ID以及最高的学生ID如下 Class Studentid 1 1 1 5 2 1 2 3 3 1 3 4 4 1 5 1 5 2I have a table with the following structure and with the data Class Studentid 11 12 13 14 15 21 22 23 31 32 33 34 41 51 52 I need to take the result The the lowest student id and the highest student id as follow as Class Studentid 11 15 21 23 31 34 41 51 52推荐答案嗨Sacraj, 我创建了一个架构,你可以以下查询获取记录Hi Sacraj,I have created a schema and you could use the below query to get the recordscreate table sellowhigh(class int,ranks int)insert into sellowhigh values(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,4),(3,1),(3,2),(3,3),(3,7),(4,2),(4,3),(4,5),(4,8)select * from sellowhighselect class,min(ranks)as ranks from sellowhigh group by class unionselect class,max(ranks)as ranks from sellowhigh group by class 班级 等级 1 1 1 4 2 1 2 4 3 1 3 7 4 2 4 8 我希望这会对你有所帮助。 问候, RKclass Ranks1114212431374248I hope this helps you a bit.Regards,RK 这篇关于如何从表中获得最低和最高的学生ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 14:08