Query editor
WITHnewround AS (SELECTvarbinary_to_uint256(topic1) as round_id,varbinary_to_uint256(data) AS startedAtFROM {{Chain}}.logsWHERE contract_address = {{Aggregator Address}}AND topic0 = 0x0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271AND block_time >= CAST( '{{Start Time}}' AS timestamp)AND block_time <= CAST( '{{End Time}}' AS timestamp)ORDER BY block_time ASC),updates AS (SELECTblock_time AS time,block_number as block,tx_hash, --I ADDED THE TX_HASH AND THE BLOCK TIME, SO WE DONT HAVE TO KEEP EDITING THE QUERYvarbinary_to_uint256(topic2) as round_id,varbinary_to_uint256(data) AS updatedAt,cast(varbinary_to_uint256(topic1) as double)/1e18 AS priceFROM {{Chain}}.logsWHERE contract_address = {{Aggregator Address}}AND topic0 = 0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5fAND block_time > CAST( '{{Start Time}}' AS timestamp)AND block_time <= CAST( '{{End Time}}' AS timestamp)ORDER BY block_time ASC),joined as (SELECTtime,block,tx_hash,u.round_id,startedAt,updatedAt,priceFROM updates as uLEFT JOIN newround as nON u.round_id = n.round_id),final as (SELECTtime,block,price,price - LAG(price) OVER (ORDER BY time) AS distance_to_previous_price,100.0 * (price - LAG(price) OVER (ORDER BY time)) / LAG(price) OVER (ORDER BY time) AS percentage_change,ROUND((to_unixtime(time) - to_unixtime(LAG(time) OVER (ORDER BY time))) / (60*60),2) AS time_difference_hours,(to_unixtime(time) - to_unixtime(LAG(time) OVER (ORDER BY time))) / 60 AS time_difference_minutes,(block - LAG(block) OVER (ORDER BY block)) AS time_difference_blocks,round_id,startedAt,updatedAt,updatedAt - startedAt as raw_start_to_update,LEAST(updatedAt - startedAt, 100) as start_to_update,LAG(LEAST(updatedAt - startedAt, 100)) OVER (ORDER BY time) as last_start_to_update,tx_hashFROM joined)