denze-e7j2NUCollection Snapshot by Token ID
Updated 2023-11-08
999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
WITH
input_contracts AS (
SELECT
*
FROM VALUES
(lower('{{nft_contract_address}}'))
AS data(nft_contract_address)
WHERE data.nft_contract_address regexp '^0x[0-9a-fA-F]{40}$' -- check address is a valid format, i.e. starts with 0x and has 42 characters total
)
, input_time AS (
SELECT
CASE
WHEN to_timestamp_ntz(data.snapshot_time) > date_trunc('minute', current_timestamp) THEN current_date + interval '1 day' - interval '1 second'
ELSE date_trunc('minute', to_timestamp_ntz(data.snapshot_time))
END AS snapshot_time
FROM VALUES
('{{snapshot_time}}')
AS data(snapshot_time)
)
, input_token_ids AS (
SELECT distinct
F.value AS input_token_ids_num
, 'tid' || F.value || '_' AS input_token_ids_string
FROM (
SELECT
SPLIT(data.input_token_id_list, '_') AS input
FROM VALUES
('{{token_ids}}')
AS data(input_token_id_list)
) i
, Table(Flatten(i.input)) AS F
)
Run a query to Download Data