— Create a view called “1919_purchases” and contains any sales where “0x1919db36ca2fa2e15f9000fd9cdc2edcf863e685” was the buyer.
CREATE VIEW 1919_purchases AS
SELECT *
FROM cryptopunks_sales
WHERE buyer_address = ‘0x1919db36ca2fa2e15f9000fd9cdc2edcf863e685’;
— Create an “estimated average value calculator” that has a representative price of the collection every day based off of these criteria:
- Exclude all daily outlier sales where the purchase price is below 10% of the daily average price
- Take the daily average of remaining transactions
a) First create a query that will be used as a subquery. Select the event date, the USD price, and the average USD price for each day using a window function. Save it as a temporary table.
b) Use the table you created in Part A to filter out rows where the USD prices is below 10% of the daily average and return a new estimated value which is just the daily average of the filtered data.
— Create an “estimated average value calculator” with specified criteria.
— Part A: Create a temporary table with the event date, USD price, and the average USD price for each day.
CREATE TEMPORARY TABLE daily_avg_prices AS
SELECT day AS event_date, usd_price,
AVG(usd_price) OVER (PARTITION BY day) AS daily_avg_price
FROM cryptopunks_sales;
— Part B: Filter out rows where the USD price is below 10% of the daily average and return a new estimated value which is just the daily average of the filtered data.
SELECT event_date, AVG(usd_price) AS estimated_avg_value
FROM daily_avg_prices
WHERE usd_price >= 0.1 * daily_avg_price
GROUP BY event_date;
I’m getting errors in results
Sudarshan S A is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.