How do I find the largest value in a column in postgres sql?

后端 未结 4 1596
南方客
南方客 2021-02-03 17:44

For example:

name | weight
jon    100    
jane   120    
joe    130

How do I only return the name of the person with the largest weight?

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-03 18:32

    SELECT name FROM tbl ORDER BY weight DESC LIMIT 1
    

    Much more performant than the other answer and results in one row only.

提交回复
热议问题