找出最高出价超过初始金额的百分比增长?

时间:2013-10-04 17:18:24

标签: sql sql-server sql-server-2008

select top 7 item_name, item_reserve, count(bid_id) as bid_count, 
max(bid_amount) as highest_bid, 
item_reserve / max(bid_amount) * 100 as pct_increase
from vb_items
join vb_bids on item_id=bid_item_id
where item_sold = 0 
group by item_name, item_reserve
order by bid_count desc

我想找到从item_reserve到highest_bid的百分比增长。我认为这或多或少是正确的,但数学并不是我的强项。

1 个答案:

答案 0 :(得分:0)

从item_reserve到highest_bid的增加百分比为:

( (highest_bid / item_reserve) - 1 ) * 100.

例如,如果它们分别是100和110,那么你有一个

((110/100)-1)*100 = (1.1 - 1) * 100 = a 10% increase.