| Author |
Topic |
|
bukworm
Starting Member
10 Posts |
Posted - 2011-06-10 : 05:04:38
|
| Hi all,I have a table from where i have to take values for a employee performance on every 20 min basis. I am using Sql report builder 3 for the report. this is the query.selectsubstring(convert(varchar,starttime.value,105), 11,2) as Hour,substring(convert(varchar,starttime.value,120), 15,2) as Minut,JobID,area,empnumfrom jobdetailswhere starttime >= convert(vchar,@date,105) and starttime < convert(vchar,@date,105)group by starttime, jobid, area, empnumthere could be more than one area for each emp, i want it by jobid, which is unique for a job, but one job could be diffrent records with diffrent times, i want it to be grouped together as one record.i am puttin this in matrix in the reportproblem is starttime is not grouped as they are different for each job, and i get duplicate jobid's.can any1 help?thanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-10 : 06:24:53
|
| with cte as(select JobID, area, empnum , starttime = MIN(starttime)from jobdetailsgroup by JobID, area, empnum)selectsubstring(convert(varchar,starttime.value,105), 11,2) as Hour,substring(convert(varchar,starttime.value,120), 15,2) as Minut,JobID,area,empnumfrom ctewhere starttime >= convert(vchar,@date,105) and starttime < convert(vchar,@date,105)group by starttime, jobid, area, empnumor maybewith cte as(select JobID, area, empnum , starttime = MIN(starttime)from jobdetailswhere starttime >= convert(vchar,@date,105) and starttime < convert(vchar,@date,105)group by JobID, area, empnum)selectsubstring(convert(varchar,starttime.value,105), 11,2) as Hour,substring(convert(varchar,starttime.value,120), 15,2) as Minut,JobID,area,empnumfrom ctegroup by starttime, jobid, area, empnum==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
bukworm
Starting Member
10 Posts |
Posted - 2011-06-13 : 10:00:56
|
| Thank you |
 |
|
|
|
|
|