Tuesday, December 31, 2013

How to display Employee Attendance Data in Crosstab Format?

You can use a query like below



SELECT EmpID,
InDate,
MAX(CASE WHEN EntryType = 'In' THEN InTime END) AS InTime,
MAX(CASE WHEN EntryType = 'Out' THEN OutTime END) AS OutTime,
CAST(DATEDIFF(minute,MAX(CASE WHEN EntryType = 'In' THEN InTime END),MAX(CASE WHEN EntryType = 'Out' THEN OutTime END))/60 AS varchar(5)) + ':' + CAST(DATEDIFF(minute,MAX(CASE WHEN EntryType = 'In' THEN InTime END),MAX(CASE WHEN EntryType = 'Out' THEN OutTime END))%60 AS varchar(2)) AS TimeDIff
FROM table
GROUP BY EMpID,InDate







Then in reporting service use a matrix container


Add EmpID to row group and InDate to Column Group. Add other fields to detail portion to get report in your format.


see attached rdl for details


matrix report




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs



No comments:

Post a Comment