sql - Get the top row after order by in Oracle Subquery -


I have a table student (id, name, department, age, score). I want to find the youngest student, which is the highest score (amongst the youngest students in each department). In SQL Server, I can use the following SQL

  Choose from student s1 * in s1.id (student s2 select s2.id where s2.department = s1 score marks top 1).  

However, in Oracle, you can not use the order by section in the sub-section and there is no limit / top like the keyword. You have to connect yourself twice. In Oracle, I use SQL

  select s1 * Students from s1, (s2.department, s2.age, max s2.score) as max sscore from student s2, (select s3.department, min (s3.age) s3.department by student s3 group Min_age) tmp1 where s2.department = tmp1.department and s2.age = tmp1.min_age group s2.department, s2.age) tmp2 where S1.department = tmp2.department and s1.age = tmp2.age and s1 .score = tmp2.max_score  

Does anyone have an idea to simplify the above SQL for Oracle?

try this one

  to choose from (SELECT ID, name , Section, age, number, ROW_NUMBER () age (division according to the age group posts from the student class, score asc) srlno = 1;  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -