SQL Lite:每次满足条件我都想加+1

SQL Lite: I want to add +1 everytime a criteria is met

所以我想检查是否满足条件,然后每次都+1。

我这样试过

SELECT Track,
 CASE 
 WHEN Duration like '%05:%' then metrics_count + 1
 WHEN Danceable = 'not very danceable' then metrics_count + 1
 WHEN Energy = 'high energy' then metrics_count + 1
 WHEN Emotion = 'moody' THEN metrics_count + 1
 WHEN  "Key" = 'C#' THEN metrics_count + 1
End as metrics_count
FROM
 table

但我只是得到空值或 1,所以它确实加起来,每次我想它都会重新启动。

看来你接下来需要

SELECT Track,
    (case when Duration like '%05:%' then 1 else 0 end) +
    (case when Danceable = 'not very danceable' then 1 else 0 end) +
    (case when Energy = 'high energy' then 1 else 0 end) +
    -- other cases
    (case when Emotion = 'moody' then 1 else 0 end) as metrics_count
FROM
 table

SQLite online test