【发布时间】:2015-03-31 07:29:25
【问题描述】:
我有一个表,我正在尝试使用 CASE 语句获取百分比
SELECT "Agent",
(100* ( max(case when "Agent"= 'Agent1' then "TOTAL" end)/
max(case when "Agent" = 'TOTAL' then "TOTAL" end) ))
as "Agent1%"
From "SumofAgent"
group by Agent
查询在新列旁边显示一个空白。我想这可能是因为价值太小了..这可能吗?
我的桌子是这样的:
Agent TOTAL
----- -----
Agent1 13
Agent2 21
Agent3 49
TOTAL 1343
(13/1343)*100=0.96%
我已经尝试了他们自己的max(case when "Agent" = 'TOTAL' then "TOTAL" end) 和max(case when "Agent"= 'Agent1' then "TOTAL" end) 的案例陈述。他们正在提取正确的值,但是当您尝试进行数学运算时,它不会显示任何内容。
使用 Zoho 报告但将使用 PostgreSQL 进行测试
【问题讨论】:
标签: postgresql case-statement zoho