Skip to main content
Get Started
Documentation

SQL query shapes for Tractorscope charts

Different chart types need different SQL result shapes. A query shape is the set of columns and rows a chart expects.

Number charts

Return one row with one or more numeric values.
select count(*) as active_users from users where is_active = 1
select count(*) as active_users from users where is_active = 1

Bar and line charts

Return a category or date column and one or more numeric values.
select date(created_at) as day, count(*) as orders
from orders
group by 1
order by 1
select date(created_at) as day, count(*) as orders
from orders
group by 1
order by 1

Series-based charts

Return a category, series, and value.
select month, plan, count(*) as accounts
from account_metrics
group by 1, 2
select month, plan, count(*) as accounts
from account_metrics
group by 1, 2

Radar charts

Return a radar dimension and one or more numeric values. For multiple radar polygons, return dimension, series, and value columns.
select dimension, team_name as series, score as value
from team_scorecard
order by display_order, team_name
select dimension, team_name as series, score as value
from team_scorecard
order by display_order, team_name

Table and download charts

Return the rows and columns viewers need to inspect or export.

Map charts

Return latitude and longitude fields, plus useful labels or values.

Related docs