sql语句将数字格式修改为字符

使用grafana创建图表时,出现错误提示:

Column metric must be of type UNKNOWN, TEXT, VARCHAR, CHAR. metric column name: metric type: INT4 but datatype is int64

意思是指准备作为metric的字段为数值类型,不支持。

需要将选择的字段数值修改为字符格式使用。

方法一:

select cast(字段 as varchar) from 表名

方法二:

select convert(varchar(50),字段) from 表名