有问题,我正在尝试计算每个员工的Total_Hours,但是在分组时会出现错误。但是,我知道问题是什么,但我不知道如何解决它。
Select
tt.uid as 'Employee',
if (tc.organisation like '%Village%' or tc.organisation like '%Personnel%', 'Village', 'Client' ) as 'Type of work',
round((sum(timestampdiff(minute, start_time, end_time))/60),2) AS 'Hours',
(select
round((sum(timestampdiff(minute, start_time, end_time))/60),2)
from timesheet.timesheet_times ttt
left outer join timesheet.timesheet_project ttp on ttt.proj_id = ttp.proj_id
left outer join timesheet.timesheet_client ttc on ttp.client_id = ttc.client_id
where
month(ttt.start_time) = month(now())
and year(ttt.start_time) = year(now())
group by
ttt.uid
)as TOTAL_HOURS_PER_EMPLOYEE,
round((
(round((sum(timestampdiff(minute, start_time, end_time))/60),2)
/
(select
round((sum(timestampdiff(minute, start_time, end_time))/60),2)
from timesheet.timesheet_times ttt
left outer join timesheet.timesheet_project ttp on ttt.proj_id = ttp.proj_id
left outer join timesheet.timesheet_client ttc on ttp.client_id = ttc.client_id
where
month(ttt.start_time) = month(now())
and year(ttt.start_time) = year(now()))
)*100),0) as percentage
from
timesheet.timesheet_times tt
left outer join timesheet.timesheet_project tp on tt.proj_id = tp.proj_id
left outer join timesheet.timesheet_client tc on tp.client_id = tc.client_id
where
month(tt.start_time) = month(now())
and tc.organisation not like '%Private%'
and year(tt.start_time) = year(now())
group by
tc.client_id
order by
round((sum(timestampdiff(minute, start_time, end_time))/60),2) desc
如果我写错了帖子,我很抱歉,这是我第一次来这里或寻求帮助。