0

我删除了之前的问题,因为事实证明我的问题是辩证的,但我仍然遇到同样的问题。所以,我的 SELECT 语句中有以下几行:

COUNT(*) AS "Number of Buildings",
COUNT(*)/ SUM(COUNT(*)) over ()*100 AS "Portfolio Percentage: Buildings",

我想做的是将“%”连接到数字结果的末尾。我试过了:

COUNT(*)/ SUM(COUNT(*)) over ()*100 || TO_NUMBER('%') AS "Portfolio Percentage: Buildings",

和:

TO_VARCHAR(COUNT(*)/ SUM(COUNT(*)) over ()*100) || '%' AS "Portfolio Percentage: Buildings",

基本上,我已经尝试了将数字转换为 CHAR/VARCHAR 或将“%”转换为数字的所有变体,这是我能想到的。它们总是返回相同的错误,这是以下的一些变体:

Numeric value '%' is not recognized
4

1 回答 1

2

问题是TO_NUMBER('%')

代替:

select COUNT(*)/ SUM(COUNT(*)) over ()*100 || TO_NUMBER('%') AS "Portfolio Percentage: Buildings"
from (select 1)

select COUNT(*)/ SUM(COUNT(*)) over ()*100 ||'%' AS "Portfolio Percentage: Buildings"
from (select 1)
于 2021-08-17T00:22:27.140 回答