我如何在laravel雄辩中做到这一点,我尝试这样做但是它给了我错误..如何在laravel中SUM( column1 + column2 )
总结两列
FileDBConsistency::join('Servers', 'Servers.srv_id', '=' , 'FileDBConsistency.srv_id')
->sum('SUM( FileDBConsistency.dbconflict + FileDBConsistency.fileconflict ) as sum')
->get( $array )
答案 0 :(得分:3)
我看到两个问题:
get()
sum()
操作的结果。DB::raw()
。这是我打开的数据库中的Tinker示例:
[1] > Priority::sum(DB::raw('priority + priority'));
// '2768'