you missed a space here:
"group by CurrentActorUID,Status,RequestedDate,ReferenceNo) a"+
should be:
"group by CurrentActorUID,Status,RequestedDate,ReferenceNo) a "+
Additionally, you can use literal '@' instead of using concatenation, something like this:
string sqlstr = @"SELECT COALESCE(engdir, 'Total') [engdir],
SUM(case when a.Status = 'Delivered' then Total else 0 end) as [Delivered],
SUM(case when a.Status = 'Completed' then Total else 0 end) as [Completed],
SUM(case when a.Status = 'Pending' then Total else 0 end) as [Pending],
SUM(case when (a.Status ='Rejected') then Total Else 0 end) as [Rejected],
COUNT(*) as Total from
(select count(*) as Total, CurrentActorUID,ReferenceNo, Status,RequestedDate from tbl_ServiceTracking
where CurrentActorUID is not null and CurrentActorUID <> '' and
JOIN PR1.dbo.GetUserDetailsE AS b
ON a.CurrentActorUID = b.PERUserName
WHERE --b.DirCode=@DirCode
(CAST(a.RequestedDate AS DATETIME)>='1/1/2014' AND CAST(a.RequestedDate AS DATETIME)<='4/30/2014')
GROUP BY b.engdir
WITH ROLLUP HAVING engdir IS NOT NULL OR GROUPING(b.engdir) = 1 ORDER BY
CASE WHEN b.engdir IS NULL THEN 1 ELSE 0 END ,b.engdir";
Run the query in your sql platform and from there you can easily check where the error came from. And just copy the query inside the literal string @"";