You're looking for MySQL's HAVING , which permits SELECT level aliases. So this: SELECT *, `column1value`-`column2value` AS `difference` ...
minus-two-columns-in-laravel
Except we're now using the minus sign instead (and reversing the two variables). When you run the script you should, of course, get the answer 10. Again, PHP .... if there are two columns gross n net then. SQL. Copy Code. select GROSS, NET, 'DIFFRENCE' = GROSS-NET From tableName if record in .... Sep 6, 2020 — App\Models\YourModel::sum(DB::raw('field1 + field2')); 939c2ea5af
Comments