I have a table with 3 columns: list_num, sales_price, and days_on_market
I want to run one query that will output a single number for the average of column 'days_on_market' with the top 5% and bottom 5% of rows removed when ordered by 'sales_price'.
I have found an example that I think would help here but the answer is too complicated for me to understand (I just started learning mySQL last week). See this example here.
Here is my code:
SELECT round(avg(days_on_market),0) as "90% Sell In"
FROM sold_q3_2016
WHERE list_num NOT IN (
SELECT list_num FROM sold_q3_2016 ORDER BY sales_price LIMIT (count(list_num)*0.05)
) OR list_num NOT IN (
SELECT list_num FROM sold_q3_2016 ORDER BY sales_price desc LIMIT (count(list_num)*0.05)
)
;
Now I can't even run this as I get the syntax error around the count function inside of the LIMIT clause but I wanted to leave it here to show my thought process. Any ideas?