- How much volume moved in each currency last week?
- How many transactions are still
INFLIGHT? - Which identities gained new wallets this month?
Write a query
ClickNew query to open a blank editor. Insights runs SQL against a data lake: a stored copy of your ledgers, balances, transactions, and identities built for reports. If you want a starter, open a template and change the filters for the report you need.
Write your first SELECT
SQL is how you ask Insights for rows from a table. Build a query in this order. Each step adds one part of the same report: how many applied transactions there are for each currency and status.1
SELECT the columns
Use This chooses the columns to return: currency, status, and a count of rows named
SELECT to choose which columns to show, or to count rows or add up a total.txn_count.2
FROM a table
Use This reads those columns from the
FROM to pick the table to read: transactions, balances, ledgers, or identity. Open Schema to see what each table stores and which columns you can select.transactions table.3
WHERE to filter rows
Use This keeps only applied transactions and drops every other status.
WHERE when you only want some rows. For example, status = 'APPLIED' keeps applied transactions and drops the rest.4
GROUP BY to summarize
Use This makes one result row for each currency and status pair, with the count for that pair.
GROUP BY when you want one result row per group, for example one row per currency and status.5
ORDER BY to sort
Use This sorts the rows so the highest counts appear first.
ORDER BY when you want the results sorted.6
LIMIT the rows
Use This returns at most 1000 rows so the workbench stays responsive.
LIMIT to cap how many rows come back. Use 1000 for listings, and stay at or under 5000.AND currency = 'USD' to the WHERE line.
Set the toolbar date range for the period you care about before you run. See How the lake works.
Use TRY_CAST on dates and amounts
When you query across many days of history, wrap dates and amounts inTRY_CAST so a type mismatch does not fail the whole query.
TRY_CAST returns NULL when a value cannot be converted to that type, instead of failing the whole query. NULLIF(..., 0) stops a divide by zero.
Sum amounts correctly
When you want to add up money, not just count rows, divideprecise_amount by precision for each row, then add those results together. Every transaction stores that value three ways. See Precision for how Core stores these fields.
precise_amount: the integer in the currency’s smallest unit (cents, satoshi).precision: how many of those units make one whole unit (100 for USD, 100000000 for BTC).amount: the human-readable value Blnk derives.
Follow these steps to total
APPLIED transaction amounts by currency.
1
Divide each row into a money value
Use
precise_amount / precision (with TRY_CAST) so each row becomes a real amount like 7.25, not 725. Use this instead of SUM(amount) when your date range covers many days of history. Do not sum precise_amount on its own: cents and satoshis are different units.DECIMAL(38, 8) means up to 38 digits in total, with up to 8 after the decimal point. That gives the division enough room to stay accurate. NULLIF(..., 0) stops a divide by zero.2
Add those values with SUM
Wrap that expression in This adds the money values across rows and returns one total called
SUM(...) and name it volume.volume.3
Group by currency
A total only makes sense inside one currency. Add
currency to SELECT and GROUP BY currency, or filter to one currency in WHERE first.4
Put it together
Full query for This returns one row per currency with the total
APPLIED transaction amounts by currency:APPLIED amount for that currency.Save a query
After you run a query you want to keep, click Save. Until you save, the draft is named Untitled lake query. Saved queries live on this instance. Open one from Saved to put that SQL back in the editor.
Schedule a query
Schedule query appears in Actions once the query is saved with no unsaved edits.- Open Actions → Schedule query.
- Pick a Preset (Hourly, Daily at 09:00, Weekly on Monday, or Monthly on the 1st). The Cron expression field fills from the preset. You can leave it as is unless you need a custom schedule.
- Confirm Timezone, then click Save schedule.
- Schedules always run the last saved version. Editor changes do not run until you save again.
- A scheduled report is the same SQL you run by hand. If a run returns empty, check the date range first.

Reopen a past run
History is past runs from this instance. Open a row to reopen a query you already executed. History is not the same list as Saved. Saved stores the query. History stores the run.
Troubleshooting
My totals do not match the dashboard
My totals do not match the dashboard
Check two things first. You summed
precise_amount without dividing by precision, or you summed across currencies. See Sum amounts correctly. Do not sum balances.balance across days for a live portfolio total. That column is a per-day copy, and current holdings belong on the Data API.Transaction counts look inflated after a join
Transaction counts look inflated after a join
balances, ledgers, and identity can repeat across days in your date range. Collapse each entity to one row per ID before you join, as in How to join them. Do not order by created_at to pick a latest wallet snapshot.Open inflight holds look wrong
Open inflight holds look wrong
Set a date range wide enough to include both the parent hold and its commit or void days. Then use the parent-child template in Open inflight holds. A bare
WHERE status = 'INFLIGHT' includes resolved parents.Query returns no rows
Query returns no rows
Check the toolbar date range first. It selects which days of history are scanned. An empty range means an empty result, even if your
WHERE clause looks right.Query fails with a type error
Query fails with a type error
A column is typed differently across days of history. Wrap comparisons and aggregates in
TRY_CAST as shown in Use TRY_CAST on dates and amounts.Query rejected: statement not allowed
Query rejected: statement not allowed
Use a
SELECT or WITH statement. Post new ledger records with the Ledger API.Query is slow or times out
Query is slow or times out
Shrink the toolbar date range, filter to fewer currencies, select named columns instead of
*, and keep a LIMIT.