2016-07-21 63 views
2

我有一個寬度和高度(兩個整數)的表。我想按原樣顯示它。 對於例如:寬度= 300和高度= 160 面積= 300×160。 我使用以下查詢在PostgreSQL中連接

select cast(concat(width,'x',height) as varchar(20)) from table; 

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. 

誰能告訴我該怎麼做? 感謝

回答

2

concat()預計字符串,而不是整數。但是您可以使用明確的演員表,就像錯誤消息所示:

select concat(width::text, 'x', height::text) 
from ...