Dynamic column alias based on column value

后端 未结 3 1113
时光说笑
时光说笑 2020-12-11 12:42

I want to name the column alias based on the column value in mysql. Is that possible?

Something like this;

select  
  case when answer_type = \'RB\'          


        
3条回答
  •  温柔的废话
    2020-12-11 13:12

    select if(answer_type="RB",'radio',if(answer_type != "RB",'everything_else',NULL)) as answer_type from XTable;

提交回复
热议问题