Using the CROSS JOIN subquery
use Illuminate\Support\Facades\DB; $totalQuery = DB::table('orders')->selectRaw('SUM(price) as total'); DB::table('orders')    ->select('*')    ->crossJoinSub($totalQuery, 'overall')    ->selectRaw('(price / overall.total) * 100 AS percent_of_total')    ->get();
Tip given by @PascalBaljet