繁体   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

该函数的名称是什么,它将给我与max(totalrentaltranscations)相对应的staff_id

也就是说,如果MaxTranscation为2000,那么staff_id拥有MaxTranscation

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