2016-08-24 88 views
0

我想添加多列並顯示另一列。這裏是我的數據庫表:從表的1行添加列值並顯示另一列

ID | firstname | lastname | score1 | score2 | score3 
1 | mark  | lupez | 5  | 7  | 4  
2 | james  | cruz  | 6  | 3  | 5  

我想添加的每一行中score1,score2和score3並顯示如下:

ID | lastname | firsname | total_score | 
1 | mark  | lupez | 16   | 
2 | james | cruz  | 14   | 

我嘗試谷歌和找到答案,但沒有運氣,我頭腦雖然不工作。

回答

4

只需添加得分列:

SELECT ID, 
     firstname, 
     lastname, 
     score1 + score2 + score3 AS total_score 
FROM yourTable 
+0

謝謝你..簡單的查詢餘did't期待.. :-) –

相關問題