Manually Using SQL
Manually Using SQL
For advanced users who need precise control over their queries, Glint provides a powerful SQL interface that lets you write, edit, and execute SQL statements directly against blockchain data. This method is ideal for users who are comfortable with SQL and want to build complex queries with filters, joins, and aggregations.
Accessing the SQL Editor Open the Query Panel on a chart portlet by clicking the Open Configuration or pencil icon. Then, select the SQL tab to switch to a code editor where you can input your custom SQL queries.

Writing Your Query Use standard SQL syntax to construct your query. You can reference any of the available tables (for example, BLOCKS, TRANSACTIONS, or TOKENS) and their columns. For instance, the query below groups data from the PRICED_TRANSFERS table for the token "SOL" within the specified date range and calculates two price metrics for each month (SOL's monthly historical average and maximum prices from January 2023 to December 2024).
SELECT
DATE_TRUNC('month', DATETIME) AS month,
AVG(USD_VALUE / NULLIF(VALUE, 0)) AS avg_price,
MAX(USD_VALUE / NULLIF(VALUE, 0)) AS max_price
FROM
PRICED_TRANSFERS
WHERE
SYMBOL = 'SOL'
AND DATETIME BETWEEN '2023-01-01' AND '2024-12-31'
GROUP BY
month
ORDER BY
month;
💡 Tip: For detailed information on available tables and columns, please refer to the Schema Reference section. This level of control lets you add complex filters, joins, and aggregations, tailoring data retrieval exactly to your needs.
Executing the Query Once your SQL statement is ready, click the Run Query button. The query results will be displayed in the Results tab of the Query Panel, allowing you to verify data correctness and refine your query as needed.
Iterative Refinement Manually writing SQL gives you the flexibility to experiment with different query structures. Modify your query to include conditions (using WHERE clauses), group data (using GROUP BY), or join multiple tables to enrich your analysis. Re-run your query each time you make adjustments to see how the output changes.
Advanced Use Cases For deep data analysis, manual SQL enables you to build multi-step queries, subqueries and leverage advanced SQL functions. This approach is particularly useful when the options provided by the Query Builder do not meet your specific requirements.
By manually writing SQL queries, you can fully leverage the power of SQL to extract, transform, and analyze onchain data exactly the way you want, ensuring granular control over your data analysis in Glint.
Last updated