How can I write complex sql query in Laravel Elequent Query Builder -
below shown query in sql server. working fine in sql server studio. how can write in laravel eloquent format?
i tried both db::table('price')... method , price::where()... model method. using both methods not able find average.
is limitation of eloquent query builder? best way output in laravel?
select month([date]) date, avg(oil) oil, avg(gas) gas, [mydatabase].[dbo].[price] year([date]) = 2017 group (month([date]))
i got answer
$result = db::select(db::raw("select month([date]) date, avg(oil) oil, avg(oil_parity) gas, [mydatabase].[dbo].[price] year([date]) = :year group (month([date]))"),['year'=>$year]); dd($result);
Comments
Post a Comment