加入收藏 | 设为首页 | 会员中心 | 我要投稿 鄂州站长网 (https://www.0711zz.com/)- 数据分析、网络、云渲染、应用安全、大数据!
当前位置: 首页 > 数据库 > MySql > 正文

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

发布时间:2020-10-19 11:47:55 所属栏目: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        

(编辑:鄂州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读