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