你好,我有一个候选人总分数表
样品
我想添加casual_wear和evening_gown,其中候选ID = 1
到目前为止我得到了什么
DB::table('total_score')
->select(DB::raw('SUM(casual_wear) as total_scores'))
->where('candidate_number', '=' , '1')
->orderBy('total_scores', 'desc')
->get();
我不知道如何添加到不同的列pls help,tnx提前
答案 0 :(得分:1)
我想添加casual_wear和evening_gown,其中候选ID = 1
那么为什么你不能在
这两个列上执行加法select casual_wear + evening_gown as some_alias
from total_score
where candidate_ID =1;
(或)你可能打算做SUM()
GROUP BY candidate_ID
喜欢
select SUM(casual_wear) as total_scores,
SUM(evening_gown) as total_scores1
from total_score
GROUP BY candidate_ID
order By SUM(casual_wear) desc;