Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want a report which looks like this


Sr. No.	Employee Name |  Task         |  Efforts in hrs |From Date |  To Date	
										
1|	Pradnya	|	Admin_reports	|	8	|	10/01/14   |  10/01/14	
			Admin_coding	|	10	|	11/01/14   |  12/01/14	
2|	Archarna|	Academic_pages	|	4	|	10/01/14   |  10/01/14	
			Timetable Reports|	16	|	10/01/14   |  12/01/14	

in the database the query is

SQL
select stEmpName ,  stCCodeName , sum(inEffortsInHrs) as hrs ,
sum(inEffortsInMins) as mins, sum(flSec) as s,
(select max(dtTaskDt) from  tblEmpTaskList where inEmpID in (@inEmpID) and
inCCodeID in (@ClaimCode)) as maxdt,
(select  min(dtTaskDt) from  tblEmpTaskList where inEmpID in (@inEmpID) and
inCCodeID in (@ClaimCode)) as mindt,
 CC.inCCodeID
from 
tblEmployeeDetails as E
inner join tblEmpClaimCode as C
on E.inEmpID=C.inEmpID
inner join tblClaimCode as CC
on CC.inCCodeID = C.inCCodeID
inner join tblEmpTaskList as T
on T.inCCodeID = CC.inCCodeID
where E.inEmpID in (@inEmpID) and CC.inCCodeID in (@ClaimCode)
group by CC.inCCodeID , stCCodeName,stEmpName


selection criteria is the employee name( multiple selection)

the problem is that it takes the same start and end date for all the tasks. I want the start and end date of particular task of particular employee. Please help me through it.
Thanks In Advance.
Posted
Updated 17-Feb-14 10:39am
v2

1 solution

You are selecting the Start and End dates incorrectly. You do not need to make sub-selects to get these values, as you have already had the tblEmpTaskList JOINed in your query. The resulting query will need to be changed to this:
SQL
select stEmpName ,  stCCodeName , sum(inEffortsInHrs) as hrs ,
sum(inEffortsInMins) as mins, sum(flSec) as s,
max(T.dtTaskDt) as maxdt,
min(T.dtTaskDt) as mindt,
CC.inCCodeID
from 
tblEmployeeDetails as E
inner join tblEmpClaimCode as C
on E.inEmpID=C.inEmpID
inner join tblClaimCode as CC
on CC.inCCodeID = C.inCCodeID
inner join tblEmpTaskList as T
on T.inCCodeID = CC.inCCodeID
where E.inEmpID in (@inEmpID) and CC.inCCodeID in (@ClaimCode)
group by CC.inCCodeID , stCCodeName, stEmpName
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900