laravel-json-query-builder
laravel-json-query-builder copied to clipboard
Add aggregation and Sql Functions Support
Aggregation and Sql Functions Support
Now you can use aggregations and some SQL functions like sum
, avg
, month
or year
in this way
ave:year:column_name
, you can also count on the group by query count:distinct:name
Return aggregations:
{
"returns": ["year:date", "month:date", "sum:value"],
"group_by": ["year_date", "month_date"]
}
Will perform SELECT year(date) as year_date, month(date) as month_date, sum(value) FROM ... GROUP BY year_date, month_date
You can also nest functions as your convenience like:
{
"returns": ["min:year:date"]
}
Will perform SELECT min(year(date)) as min_year_date FROM ...
You can read more on SQLFunctions and DatabaseFunctions