Here’s a thought: data isn’t just numbers; it’s people.
Every transaction on-chain is someone making a choice:
➡️ Buying into a protocol.
➡️ Swapping tokens in search of opportunity.
➡️ Holding on tight because they believe in the vision.
If you only look at the numbers, you’ll miss the heartbeat.
But when you combine the numbers with context, you uncover the real story.
That’s what separates good analysts from great analysts.
This query analyzes contract deployments on the Sonic blockchain from a specific date forward. It categorizes and counts the total number of unique contracts deployed, distinguishing between those created by a factory contract and those deployed directly.
Query Breakdown
The query performs a simple but powerful aggregation using COUNT and CASE statements.
SELECT clause: This is where the results are defined.
COUNT(DISTINCT address) AS total_contracts: This counts every unique contract address that meets the criteria in the WHERE clause. This gives the total number of new, distinct contracts.
COUNT(CASE WHEN factory THEN 1 END) AS factory_deployed_contracts: This is a conditional count. It checks the factory column for each row. If the value in this column is TRUE (or a similar boolean representation), it counts that row. This effectively tallies the number of contracts created by a factory.
COUNT(CASE WHEN NOT factory THEN 1 END) AS direct_deployed_contracts: This is similar to the previous line but counts the opposite. If the factory column is FALSE, it counts the row, which represents a contract that was deployed directly without using a factory.
FROM sonic.contracts: The data is sourced from the sonic.contracts table, which presumably contains a record for each smart contract on the Sonic blockchain, along with metadata about how it was created.
WHERE created_at >= CAST('2024-12-19' AS TIMESTAMP): This filter restricts the analysis to a specific time frame. It ensures that only contracts created on or after December 19, 2024, are included in the counts.
In summary, the query efficiently scans a table of smart contracts and, in a single pass, provides a summary of the total contracts deployed since a certain date, broken down by whether they were created via a factory contract or not.
Our learners don’t just study SQL, they create real dashboards that solve real problems.
Here’s an image of one of our Alumni’s Dashboard;
Read more: https://dune.com/defi__josh/unmasking-dollarme-adoption-and-user-behavior-after-tge-and-airdrop
This isn’t just practice dashboard, it’s proof that learning SQL and on-chain analysis opens doors to building things that matter and tell a story.
Become a Blockchain Data Analyst
Learn Onchain Analysis using SQL and Dune in our hands-on, guided training program.
Deadline: 30th Sept, 2025
Start Date: 1st Oct, 2025
Read details and Secure Your Spot here:
https://analyticsages.io/beginner-blockchain-analytics-sql/
This is your chance to learn the skills that power dashboards, insights, and data-driven decision-making in Web3. Don’t miss it.
No posts

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.