how to calculate the percentage in sql
In the below select statement the client wants to have percentage of (t.regularhours) instead of sum(t.regularhours) how to calculate thepercentage please help me out .
SELECT
ISNULL(w.Name, 'N/A') AS WorkGroupName,
'Project' as TimeType,
case when res.employeetype ='NT' then 'NTNI'
when res.employeetype= 'EM' then 'Employee'
when res.employeetype= 'CO' then 'Contractor'
when res.employeetype= 'MC' then 'Management Consultant'
when res.employeetype= 'OS' then 'Offshore'
end Employeetype,
Sum(t.RegularHours) AS RegularHours
FROM
Time t (NOLOCK) LEFT OUTER JOIN
Workgroupmember wgm (NOLOCK) ON t.ResourceId = wgm.ResourceId and t.WorkgroupId=wgm.WorkgroupId and t.GlobalWorkgroupId=wgm.GlobalWorkgroupId LEFT OUTER JOIN
Workgroup w (NOLOCK) ON w.WorkgroupId = wgm.WorkgroupId and w.deleted = 0 LEFT OUTER JOIN
GlobalWorkgroup gwg (NOLOCK) ON wgm.GlobalWorkgroupId = gwg.GlobalWorkgroupId LEFT OUTER JOIN
Resources res (NOLOCK) ON wgm.ResourceId = res.ResourceId
where timedate >'12/10/2005' and approvalstatus='A' and w.obs like '00001.00004.00001%'
group by w.name,res.employeetype
|