【发布时间】:2020-06-19 23:30:08
【问题描述】:
我有两张表如下:
桌人
------------------------------
idpers | name | firstname
------------------------------
1 | John | Miad
2 | Eddy | Rowan
3 | Phil | Barzoon
...
表任务
-----------------------------------------------------------------------
id_td | date | task | protocol
-----------------------------------------------------------------------
211 | 13-12-19 | Mount | 13-12-19•John Miad→13-12-19•Eddy Rowan
348 | 14-12-19 | Fix and clean | 14-12-19•Eddy Rowan
256 | 15-12-19 | Lubricate | 15-12-19•Phil Barzoon
265 | 15-12-19 | First run | 15-12-19•Phil Barzoon→15-12-19•John Miad
...
我想创建一个视图 DAILY_TOTAL_BY_DOER,它为每个名称计算像这样完成的任务数
查看示例:
enter code here
------------------------------------------------------------------------
date | idpers | name | firstname | total_tasks
------------------------------------------------------------------------
13-12-19 | 1 | John | Miad | 7
13-12-19 | 2 | Eddy | Rowan | 3
13-12-19 | 3 | Phil | Barzoon | 8
14-12-19 | 6 | Andreas | werner | 5
...
非常感谢您的帮助。
【问题讨论】:
-
你尝试了什么,出现了什么问题?
-
嗨,我尝试了 SELECT name, firstname,(SELECT count(case when protocol like '%'+name+'%' then 1 else null end) FROM tasks) 作为 tottd FROM 人员,但没有总数..只是 0
标签: sqlite select count wildcard