See 3 changes to your code in red. Also, see this thread:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=171526select(((select max (price) from (select top(50) percent price from data where price is not null and solddate >= (select dateadd(month,0,getdate())-1,0)) order by price) as m1) +(select min(price) from (select top(50) percent price from data where price is not null and soldate >= (select dateadd(month,0,getdate())-1,0)) order by price DESC)as m2))/2)