Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有表stud_id(key,name,standard,marks)。我想从每个中选择礼帽standard。以下查询会起作用吗?
stud_id
key,name,standard,marks
standard
SELECT DISTINCT( standard ), stud_id, name, marks FROM table WHERE marks = Max(marks) GROUP BY standard
如果你想要marks每个的顶部standard,那么你可以使用:
marks
select t1.standard, t1.stud_id, t1.name, t1.marks from table t1 inner join ( select standard, max(marks) TopMarks from table group by standard ) t2 on t1.standard = t2.standard and t1.marks = t2.topmarks