-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_tx_types.sql
More file actions
37 lines (35 loc) · 812 Bytes
/
fetch_tx_types.sql
File metadata and controls
37 lines (35 loc) · 812 Bytes
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
37
-- Query to fetch one transaction of each type from the transactions table
-- This will help verify our parsing logic and see what message types are in the DB
SELECT
type,
hash,
sender,
recipient,
amount,
fee,
memo,
status,
timestamp,
chain,
tx_data
FROM (
SELECT
*,
ROW_NUMBER() OVER (PARTITION BY type ORDER BY timestamp DESC) as rn
FROM transactions
WHERE type IS NOT NULL
AND type != 'unknown'
) ranked
WHERE rn = 1
ORDER BY type;
-- Alternative query to see all unique types and their counts
-- SELECT
-- type,
-- COUNT(*) as count,
-- MIN(timestamp) as first_seen,
-- MAX(timestamp) as last_seen
-- FROM transactions
-- WHERE type IS NOT NULL
-- AND type != 'unknown'
-- GROUP BY type
-- ORDER BY count DESC;