答案 0 :(得分:0)
您只需添加它们
SELECT SUM(indoor_km) + SUM(outdoor_km)
FROM...
要仅选择一个时间段的总和,只需使用WHERE
或BETWEEN
添加一个>=, <=
子句,在示例中就使用了后者。
SELECT SUM(indoor_km) + SUM(outdoor_km)
FROM Fietsen_2018
WHERE datum >= '1/01/2018' AND datum <='31/01/2018'
答案 1 :(得分:0)
您可以在条件上使用SUM
函数,以便对满足IS NOT NULL
条件的条目进行计数:
select
sum( case when indoor_km is not null then 1 else 0 end ) As indoorKmCount,
sum( case when outdoor_km is not null then 1 else 0 end ) As outdoorKmCount
from table