Think before you speak, read before you think.

mysql ELT 替换返回的列

by

in

统计数量的时候,select 返回值是

1 | 138
2 | 234
3 | 22
4 | 348

想要把最前面的代号换成有意义的字符串

select
  ELT(app_code, "dev", "demo", "demo1", "prod") as env,
  count(*)
from
  app_overview
where
  last_deployed_tag != ""
group by
  app_code;

结果为

dev   | 138
demo  | 234
demo1 | 22
prod  | 348

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *