简体   繁体   English

id的值对应于另一列的最大值

[英]Value of id corresponding to max value of another column

select 
    max(totalrentaltranscations) as MaxTranscations,
    firstsortedvalue(staff_id,totalrentaltranscations) as ID 
from Table

what is the name of the function that will give me the staff_id corresponding to max(totalrentaltranscations) 该函数的名称是什么,它将给我与max(totalrentaltranscations)相对应的staff_id

that is if MaxTranscation was 2000, what staff_id had MaxTranscation 也就是说,如果MaxTranscation为2000,那么staff_id拥有MaxTranscation

Use order by + limit : order by + limit使用order by

select 
    staff_id as id,
    totalrentaltranscations
from a_table
order by 2 desc
limit 1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM