首页 MySql mysql – 在行和回显编号和列名中查找最高值

mysql – 在行和回显编号和列名中查找最高值

经过几个小时后,我找不到答案.首先我的桌子 id | one | two | three | four | five | galname ————————————————- 1 | 2 | 5 | 23 | 4 | 5 | Bob 如何在行中找到最高值并显示c

经过几个小时后,我找不到答案.

首先我的桌子

  id | one | two | three | four | five | galname
-------------------------------------------------
  1  |  2  |  5  |   23  |  4   | 5    |  Bob

如何在行中找到最高值并显示colomun名称.

three - 23

最佳答案

 select  id,GREATEST(one,two,three,four,five) value,case GREATEST(one,five)
         when one then 'one'
         when two then 'two'
         when three then 'three'
         when four then 'four'
         when five then 'five' end column_name
 from your_table        

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/shujuku/mysql/20201019/11225.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部