0
我有一個表,ROTAS志願者:peewee複雜的查詢,如果
dater | vol1id | vol2id | vol3id | vol4id
-----------+------------+-----------+----------+-----------
2017-08-01 | 1 | 13 | 14 | 33
2017-08-02 | 32 | 150 | 3 | 4
一個老查詢的檢查有多少志願者已經都準備好了一天,所以它在一個HTML表中所示顏色取決於可用性。這樣做是這樣的:
SELECT
(CASE WHEN vol1id IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN vol2id IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN vol3id IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN vol4id IS NULL THEN 0 ELSE 1 END)
FROM rotas
WHERE (dater BETWEEN '2017-08-01' AND '2017-08-31')
ORDER BY dater;
我想這個SQL查詢轉換爲peewee過濾,將有可能被用做peewee?