我希望对多个列中的数值进行计数,并将总数计入一个名为'car_total'的新列中
我尝试了一个精选案例,但没有成功
结果应如下所示:
|car_id | merc | toyota | fiat | car_total
+-------+------+--------+-------+----------
|123567 | 1 | 0 | 0| 1
|567888 | 0 | 1 | 1 | 2
答案 0 :(得分:0)
您可以使用下面的sql查询在新列中获取总数
ForFiles /P "%UserProfile%\Desktop\folder" /S /C "Cmd /C If /I Not @ext==0x22lnk0x22 If /I Not @ext==0x22url0x22" Del /A /F @path"
答案 1 :(得分:0)
SELECT car_id,
merc,
toyota,
fiat,
Sum(merc + toyota + fiat) AS car_total
FROM table_name
OR
SELECT car_id, SUM(mers+toyota +fiat ) AS car_total FROM Cars Group By Id