英文:
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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论