Dune Analytics Launches a Beginner‑Friendly Walk‑Through for Building Your First DeFi Query
April 2024 – Dune, the on‑chain analytics platform that powers thousands of public dashboards, has released a step‑by‑step tutorial aimed at users who are new to SQL and DeFi data exploration. The guide, titled “Create your first query,” walks readers through constructing a basic yet insightful query that measures daily decentralized‑exchange (DEX) trading volumes across multiple blockchains. While the tutorial is clearly aimed at newcomers, it also highlights several capabilities that seasoned analysts will find useful for rapid prototyping and cross‑chain comparisons.
Why the Tutorial Matters
- Lowering the entry barrier – By pairing a plain‑English overview with a ready‑made SQL script, Dune helps users who are familiar with DeFi concepts but lack a background in data‑engineering to start extracting on‑chain metrics immediately.
- Standardised, curated data – The platform provides a “curated” data layer that abstracts away the messy raw blockchain tables. For DEX activity, the tutorial points to the
dex.tradestable, which consolidates transaction data from dozens of protocols and chains into a uniform schema. - Immediate visual feedback – The tutorial shows how to turn query results into bar‑charts within the Dune UI, reinforcing the “analysis‑to‑visualisation” loop that many analysts rely on for stakeholder communication.
The Core Steps Outlined in the Guide
| Step | What the guide covers | Practical outcome |
|---|---|---|
| 1. Create a new query | Users navigate to Dune’s query editor and start a fresh notebook. DuneSQL, a dialect compatible with TrinoSQL, powers the language. | A sandbox where SQL statements can be executed against Dune’s data warehouse. |
| 2. Choose the right table | The tutorial directs readers to the Data Catalog, then highlights dex.trades as the source for cross‑chain DEX data. |
Access to a pre‑joined, analytics‑ready table that already normalises fields such as trade amount (USD) and blockchain identifier. |
| 3. Build a baseline query | A simple SELECT aggregates daily trade counts and USD volume per blockchain for the past 30 days. It uses block_date, blockchain, COUNT(*), and SUM(amount_usd). |
A table that shows, for each day, which chains are most active and how much value they moved. |
| 4. Add a parameter for interactivity | By inserting a text parameter called “Project Name,” the query can be filtered on a specific DEX (e.g., Uniswap or Curve). | Users can instantly toggle the view to compare individual protocol performance without rewriting SQL. |
| 5. Visualise the output | The guide walks through creating a stacked bar chart that groups daily volume by blockchain. | A ready‑to‑share visual that conveys trends at a glance, suitable for dashboards or presentations. |
| 6. Save and iterate | Once satisfied, users click “Save,” pin the query to a dashboard, and can later expand it—e.g., by adjusting the time window or adding token‑level filters. | A reusable analytics asset that can evolve as research questions deepen. |
Sample Query (Paraphrased)
sql
SELECT
block_date,
blockchain,
COUNT(*) AS number_of_trades,
SUM(amount_usd) AS trading_volume_usd
FROM dex.trades
WHERE block_date >= NOW() – INTERVAL ’30’ DAY
GROUP BY block_date, blockchain
ORDER BY block_date DESC, trading_volume_usd DESC;
A second version adds the project column and a text parameter, allowing analysts to focus on a single DEX:
sql
…
WHERE block_date >= NOW() – INTERVAL ’30’ DAY
AND project = ‘{{Project Name}}’ — e.g., ‘uniswap’
…
GROUP BY block_date, blockchain, project;
Both scripts demonstrate the platform’s ability to slice and dice on‑chain activity with minimal boilerplate.
Analyst’s Perspective
The tutorial showcases a few best practices that merit attention:
- Time‑bounded windows – Restricting analysis to recent periods (
NOW() - INTERVAL '30' DAY) reduces data volume and surfaces current market dynamics, which are especially volatile in DeFi. - Parameterisation – Embedding UI‑driven variables (
{{Project Name}}) encourages exploratory analysis without the overhead of multiple saved queries. - Cross‑chain comparability – Since
dex.tradesnormalises fields across EVM‑compatible chains, the same query instantly yields side‑by‑side metrics for Ethereum, Polygon, Arbitrum, and others. This is crucial for investors tracking flow migration.
For power users, the guide’s simplicity is a springboard: the same table supports granular joins (e.g., adding token symbols or fee structures) and can be combined with other curated datasets such as liquidity provider rewards or on‑chain governance events.
Key Takeaways
- Quick onboarding – Dune’s new tutorial makes it feasible for anyone with basic SQL knowledge to generate meaningful DeFi analytics in under an hour.
- Curated data advantage – Leveraging the
dex.tradestable eliminates the need to manually parse raw logs, accelerating time‑to‑insight. - Interactivity through parameters – The built‑in parameter UI turns static queries into dynamic dashboards that can be toggled on the fly.
- Visualisation integration – Bar‑chart creation is a single click away, reinforcing the platform’s end‑to‑end analytics workflow.
- Scalable foundation – The query can be expanded with additional filters (token, fee tier) or longer windows, serving as a reusable component for more sophisticated research.
Looking Ahead
Dune’s “Create your first query” tutorial is part of a broader effort to democratise on‑chain analytics, positioning the platform as a go‑to resource for both novice traders and institutional researchers. By offering a clear path from data discovery to visual storytelling, Dune helps the DeFi ecosystem surface actionable insights—whether it’s tracking an emerging DEX’s growth trajectory or monitoring capital flows between L1 and L2 networks.
Users interested in extending the example can explore the public “DEX Trading Activity” dashboard linked from the tutorial, or dive into other guides that cover advanced topics such as window functions, sub‑queries, and custom visualisations.
For more detailed steps and the full SQL code, visit Dune’s documentation at https://docs.dune.com/learning/how-tos/create-your-first-query.
Source: https://docs.dune.com/learning/how-tos/create-your-first-query
