Home > database >  After oracle group, get the id of the minimum performance and classes and grades
After oracle group, get the id of the minimum performance and classes and grades

Time:09-20

Oracle data tables below the primary key id is uuid not Numbers

Need to get the results

Using the following SQL query result without id, I'm going to get the minimum scores the id of the

CodePudding user response:

The select scoreid, kc, cj
The from score b
Left the join (select Max (cj) as cj, kc from score a group by kc) on the biggest j c=Arthur c. j and c=c.k b.k c;

If there are multiple minimum scores, there will be multiple data,

CodePudding user response:

Quote: refer to 1st floor weixin_42581861 response:

The select scoreid, kc, cj
The from score b
Left the join (select Max (cj) as cj, kc from score a group by kc) on the biggest j c=Arthur c. j and c=c.k b.k c;

If there are multiple minimum scores, there will be multiple data,

With group by as the main table to link again

CodePudding user response:

 select distinct 
First_value (id) over (partition by kc order by cj desc) id,
Kc,
Min (cj) over (partition by kc) cj
The from student;

CodePudding user response:

 
Select id, kc, cj
The from (select id,
Kc,
Cj,
Row_number () over (partition by kc order by cj) as an rn
From the table)
Where an rn=1;

  • Related