Five examples of raw SQL usage with MySQL database.
Below are five raw SQL with MySQL syntax examples, along with the location where you can find them so you can explore more.
app/Filament/Resources/MetricResource.php:
return $table ->modifyQueryUsing(function (Builder $query) { $query->select( [ 'id', 'server_id', DB::raw('created_at as date'), DB::raw('ROUND(AVG(`load`), 2) as `load`'), DB::raw('ROUND(AVG(memory_total), 2) as memory_total'), DB::raw('ROUND(AVG(memory_used), 2) as memory_used'), DB::raw('ROUND(AVG(memory_free), 2) as memory_free'), DB::raw('ROUND(AVG(disk_total), 2) as disk_total'), DB::raw('ROUND(AVG(disk_used), 2) as disk_used'), DB::raw('ROUND(AVG(disk_free), 2) as disk_free'), ], ) ->groupByRaw('server_id');