2013-10-04 69 views
1
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的增長百分比。我認爲這或多或少是正確的,但數學並不完全是我的強項。找出最高出價比初始金額增加的百分比?

+0

豈不是另一種方式周圍? 'MAX(BID_AMOUNT)/ item_reserve)'? – zimdanen

+0

這不僅僅是一個簡單的數學問題嗎? –

+0

這是數學,但確實需要在SQL上下文中完成 - 有些數學既不能完成,也很難在其中完成。 – Plasmarob

回答

0

從item_reserve增加百分之highest_bid是:

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

例如,如果他們是100和110,分別,你有一個

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