如何在SQL中计算与总物业价格相对的物业价格百分比?

huangapple go评论62阅读模式
英文:

how to calculate the percentage of property prices in relation to the total amount of property prices in sql?

问题

如何在SQL中计算与总房产价格相对的百分比?

我将房产状态价格除以所有州的总价格。我是SQL新手,正在摸索中。谢谢

英文:

how to calculate the percentage of property prices in relation to the total amount of property prices in sql?

I took the property state price and divide it by the total prices of all states. I am a new in sql. I am just figuring it out. thanks

答案1

得分: 1

以下是翻译好的内容:

我相信你正在寻找类似这样的内容:

选择属性名称,价格,(价格/总价格)* 100 作为百分比
从你的表
交叉连接(选择SUM(价格)作为总价格从你的表)作为t;
英文:

I believe you are looking something like this:

SELECT property_name, price, (price / total_price) * 100 AS percentage
FROM your_table
CROSS JOIN (SELECT SUM(price) AS total_price FROM your_table) AS t;

huangapple
  • 本文由 发表于 2023年6月26日 16:41:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554982.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定