TASK #239 · Hard · WallapopMedian Time to Sell by Category
Your brief
The time to sell a listing is the number of days between published_date and
sold_date in listings. Unsold listings (sold_date is NULL) are
ignored.
Write a query that for each category returns category, the number of sold listings sold_listings, the average time to sell avg_days, and the median time to sell median_days; round both values to two decimals. With an even number of sales, the median is the average of the two middle values. Sort the result by median_days ascending and, in case of a tie, by category.
Write a query that for each category returns category, the number of sold listings sold_listings, the average time to sell avg_days, and the median time to sell median_days; round both values to two decimals. With an even number of sales, the median is the average of the two middle values. Sort the result by median_days ascending and, in case of a tie, by category.
Ctrl / ⌘ + ↵
Result
Write a query and run it to see the results.
Schema
usersuser_id, user_name, city, signup_datelistingslisting_id, seller_id, title, category, price, published_date, sold_date, buyer_idchatschat_id, listing_id, buyer_id, started_date