These examples omit filter, sorts, and range, for brevity. They can be run against the Bond Prices demo.
Supply an empty groupings array (or omit groupings entirely), and only provide one measure.
{
"groupings": [ ],
"measures": [ { "function": "RECORD_COUNT" } ]
}
SELECT COUNT(*)
FROM table
{
"schema": {
"fields": [
{ "name": "RECORD_COUNT", "type": "NUMBER" }
]
},
"records": [
[ 892 ]
]
}
Supply an empty groupings array (or omit groupings entirely), and only provide one measure.
{
"measures": [
{ "inputField": "Issue Date", "function": "MIN" },
{ "inputField": "Issue Date", "function": "MAX" },
{ "inputField": "Coupon", "function": "MIN" },
{ "inputField": "Coupon", "function": "MAX" }
]
}
SELECT MIN(Issue_Date), MAX(Issue_Date), MIN(Coupon), MAX(Coupon)
FROM table
{
"schema": {
"fields": [
{
"name": "Issue Date (MIN)",
"type": "DATE"
},
{
"name": "Issue Date (MAX)",
"type": "DATE"
},
{
"name": "Coupon (MIN)",
"type": "NUMBER"
},
{
"name": "Coupon (MAX)",
"type": "NUMBER"
}
]
},
"records": [
[ "1984-08-15T23:00:00Z", "2005-06-29T23:00:00Z", 0.5, 12.625 ]
]
}
Note that dates are always exchanged in JSON using strings with the ISO 8601 format or same but with time element omitted.
E.g. to plot a simple Bar chart.
{
"groupings": [ { "field": "Category" } ],
"measures": [ { "function": "RECORD_COUNT" } ]
}
SELECT Category, COUNT(*)
FROM table
GROUP BY Category
{
"schema": {
"fields": [
{
"name": "Category",
"type": "TEXT"
},
{
"name": "RECORD_COUNT",
"type": "NUMBER"
}
]
},
"records": [
[ "Collateralised", 136 ],
[ "Senior Unsecured", 438 ],
[ "Subordinated", 192 ],
[ "Supranational", 126 ]
]
}
Use 2 groupings and empty or missing measures. E.g. to create a 2 tier tree.
{
"groupings": [
{ "field": "Category" },
{ "field": "Is Split" }
]
}
SELECT Category, Is_Split
FROM table
GROUP BY Category, Is_Split
{
"schema": {
"fields": [
{
"name": "Category",
"type": "TEXT"
},
{
"name": "Is Split",
"type": "TEXT"
}
]
},
"records": [
[ "Collateralised", "N" ],
[ "Collateralised", "Y" ],
[ "Senior Unsecured", "N" ],
[ "Senior Unsecured", "Y" ],
[ "Subordinated", "N" ],
[ "Subordinated", "Y" ],
[ "Supranational", "N" ],
[ "Supranational", "Y" ]
]
}
A nested inner query obtains the unique values. The outer query counts the rows. This gives a 1x1 cell table containing the unique value count.
{
"@visokiotype": "QueryApi.AggregateQuery",
input: {
"@visokiotype": "QueryApi.AggregateQuery",
"groupings": [ { "inputField": "Composite Rating" } ]
},
"groupings": [],
"measures": [ { "function": "RECORD_COUNT" } ]
}
The above query yields an overall unique value count. If you want to split this by a field, here’s the variant. This yields a 2 column table, first typically being a bar view’s split labels, second being the bar view’s measure value.
{
"@visokiotype": "QueryApi.AggregateQuery",
input: {
"@visokiotype": "QueryApi.AggregateQuery",
"groupings": [
{ "inputField": "Composite Rating" },
{ "inputField": "Category" }
]
},
"groupings": [
{ "inputField": "Category" }
],
"measures": [
{ "function": "RECORD_COUNT", "name": "Unique ratings count" }
]
}