我有一个带有宽度和高度(均为整数)的表格。我想按原样显示它。
例如:宽度 = 300,高度 = 160。
面积 = 300 x 160。
我正在使用以下查询
select cast(concat(width,'x',height) as varchar(20)) from table;
or
select concat(width,'x',height) from table;
但我收到以下错误。
ERROR: function concat(character varying, "unknown", character varying) does not exist
Hint: No function matches the given name and argument types. You may need to add explicit type casts.
谁能告诉我该怎么做?
谢谢
Use ||
按照:https://www.postgresql.org/docs/current/static/functions-string.html https://www.postgresql.org/docs/current/static/functions-string.html
SELECT COALESCE(width, '') || 'x' || COALESCE(height, '') FROM your_table;
小提琴样本:http://sqlfiddle.com/#!15/f10eb/1/0 http://sqlfiddle.com/#!15/f10eb/1/0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)