这是我正在尝试的查询。
select
UserId,
count(e.UserId) as 'Experiments',
count(t.TaskId) as 'Tasks tried',
count(case when t.TaskStatus = 'Completed' then t.TaskStatus end) as 'Tasks completed',
sec_to_time(avg(timediff(TaskLocalUserEndDateTime,TaskLocalUserStartDateTime))) as 'Average Time'
from
Tasks as t,
Experiments as e
where
t.ExperimentId = e.ExperimentId
and
e.UserId = e.UserId
group by
UserId;
count(e.UserId)
count(t.TaskId)
给出与哪个错误相同的结果。但是count()
,如果我在没有任何连接的情况下运行查询,则会返回正确的结果,例如:
select
count(UserId)
from
Experiments
where
UserId = UserId
group by
UserId;