问题描述
我无法解决这个问题.
我需要获取30%的整数,然后将整个列减少该数量.
首先,我有:
Can''t get my head around this.
I need to get 30% of an integer and then reduce the entire column by that amount.
First off I have:
SELECT Quantity, (COUNT(Quantity)*100/(Select COUNT(*) From FishStock)) as Score
FROM Stock
Group By Quantity
在新的查询列中返回50%.我无法理解数学将其转换为30%的方法,而且我真的不知道如何将这个数字删除到实际数据库中.
非常感激任何的帮助.即使您只是指出正确的方向.
Which returns 50% in a new query column. Can''t get my head around the maths to convert that to 30% and I literally have no idea how to remove that number to the actual database.
Any help would be most appreciated. Even if you just point me in the right direction.
Thanks.
推荐答案
SELECT Quantity, Quantity * 30 / 100 as Score
FROM Stock
Group By Quantity
应在分数"列中为您提供30%的数量,
要将其保存在数据库中,您需要使用UPDATE
query.Update Stock Set Quantity = Quantity * 30 / 100
将所有数量更新为初始值的30%.使用此查询时要格外小心.
should give you 30% of quantity in the Score column,
To save this in the database, you need to use an UPDATE
query.Update Stock Set Quantity = Quantity * 30 / 100
will update all quantities to 30% of their initial values. Use this query with extreme caution.
这篇关于SQL查询百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!