Skip to content

Commit 2dd01ed

Browse files
0xBoxergitbook-bot
authored andcommitted
GitBook: [dev] 3 pages modified
1 parent e5b765c commit 2dd01ed

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* [Ecosystem Dashboards](about/usecases/ecosystem-dashboards.md)
1111
* [Tutorials](about/tutorials/README.md)
1212
* [Dune Guides](about/tutorials/dune-guides/README.md)
13-
* [Tips](about/tutorials/dune-guides/tips.md)
13+
* [Tips for querying](about/tutorials/dune-guides/tips.md)
1414
* [SQL guides](about/tutorials/sql-guides.md)
1515
* [Video Series](about/tutorials/video-series.md)
1616

about/tutorials/dune-guides/tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tips
1+
# Tips for querying
22

33
You can interact with the data tables through our interface at [duneanalytics.com](https://www.duneanalytics.com/).
44

data-tables/data-tables/labels.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,53 +112,50 @@ If you want to have labels for these addresses simply alter the `trader_a` colum
112112
> Note: In the examples below `---` represents lines removed, and `+++` lines added.
113113
114114
```sql
115-
--- SELECT trader_a, SUM(token_a_amount)
116-
+++ SELECT labels.get(trader_a), SUM(token_a_amount)
115+
SELECT trader_a, labels.get(trader_a) as label, SUM(token_a_amount)
117116
FROM dex.trades
118117
WHERE token_a_symbol = 'DAI'
119118
AND block_time > now() - interval '24 hours'
119+
and not labels.get(trader_a) isnull
120120
GROUP BY 1
121-
ORDER BY 3 DESC
122-
LIMIT 10;
121+
ORDER BY 2 DESC
122+
LIMIT 100;
123123
```
124124

125125
Now you’ve replaced the addresses with lists of all labels for trader\_a. Sometimes you’re only interested in a subset of labels: `labels.get` accepts an optional list of type names which filter the type of labels you get. Say you’re only interested in ‘activity’ labels:
126126

127127
```sql
128-
--- SELECT labels.get(trader_a), SUM(token_a_amount)
129-
+++ SELECT labels.get(trader_a, 'activity'), SUM(token_a_amount)
128+
SELECT trader_a, labels.get(trader_a, 'activity') as label, SUM(token_a_amount)
130129
FROM dex.trades
131130
WHERE token_a_symbol = 'DAI'
132131
AND block_time > now() - interval '24 hours'
132+
and not labels.get(trader_a) isnull
133133
GROUP BY 1
134-
ORDER BY 3 DESC
135-
LIMIT 10;
134+
ORDER BY 2 DESC
135+
LIMIT 100;
136136
```
137137

138138
Of course you can also show the address, and filter for multiple label types
139139

140140
```sql
141-
--- SELECT labels.get(trader_a, 'activity'), SUM(token_a_amount)
142-
+++ SELECT trader_a, labels.get(trader_a, 'activity', 'project', 'contract_name') as labels, SUM(token_a_amount)
141+
SELECT trader_a, labels.get(trader_a, 'activity', 'project', 'contract_name') as label, SUM(token_a_amount)
143142
FROM dex.trades
144143
WHERE token_a_symbol = 'DAI'
145144
AND block_time > now() - interval '24 hours'
146-
--- GROUP BY 1
147-
+++ GROUP BY 1, 2
148-
ORDER BY 3 DESC
149-
LIMIT 10;
145+
and not labels.get(trader_a) isnull
146+
GROUP BY 1
147+
ORDER BY 2 DESC
148+
LIMIT 100;
150149
```
151150

152151
You can also use `labels.url` to make the addresses clickable:
153152

154153
```sql
155-
--- SELECT trader_a, labels.get(trader_a, 'activity') as labels, SUM(token_a_amount)
156-
+++ SELECT labels.url(trader_a), labels.get(trader_a, 'activity') as labels, SUM(token_a_amount)
154+
SELECT labels.url(trader_a), labels.get(trader_a, 'activity') as labels, SUM(token_a_amount)
157155
FROM dex.trades
158156
WHERE token_a_symbol = 'DAI'
159157
AND block_time > now() - interval '24 hours'
160-
--- GROUP BY 1
161-
+++ GROUP BY 1, 2
158+
GROUP BY 1, 2
162159
ORDER BY 3 DESC
163160
LIMIT 10;
164161
```

0 commit comments

Comments
 (0)