从一列获得三行的总和?

use*_*472 -2 sql

我有一个表,其中的数据看起来类似于:

user  type       hours    used    --to make another column with this info    available

2334  sick       10.000   2.000                                              8.000
2334  vacation   48.000   56.000                                             -8.000
2334  personal   0        8.000                                              0
1356  sick       0        16.000                                             -16.000
1356  vacation   80.000   0                                                  80.000
1356  personal   14.000   14.000                                             0
4355  sick       4.000    1.000                                              3.000
4355  vacation   112.000  0                                                  112.000 
4355  personal   8.000    0                                                  8.000
Run Code Online (Sandbox Code Playgroud)

我必须总结小时列中的值,但仅限每个用户.因此,用户2334可以获得58.000小时数,10.000 + 48.000 + 0但会花费66.000数小时的-8.000时间.

Joh*_*Woo 7

SELECT user, SUM(hours) totalHours
FROM tableName
GROUP BY user
Run Code Online (Sandbox Code Playgroud)