SELECT st.assid, st.staffid, (SUM(DATDIFF(minute, wt.starttime,wt.stoptime) / MAX(st.estimatedduration)) * 100 AS status FROM staff st JOIN wortime wt ON st.assid = wt.fk_assid GROUP BY assid, staffid>I've 2 tables.assignment(pk) and worktime(fk)
>assid, staffid,estimatedduration,status(i.e how much % an assignemt completed) >381 ellen 1d 35(rough figures) >382 karl 12h 75 >383 RAJ 6min 60 >wortime table >----- >fk_assid,starttime,stoptime >381 2003-12-03 10:53:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 12:12:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 10:29:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 10:44:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 10:32:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 10:27:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 13:49:00.000 2003-12-03 13:49:42.640 >381 2003-12-03 10:51:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 13:51:00.000 2003-12-03 13:51:26.467 >381 2003-12-03 10:52:00.000 2003-12-03 13:49:00.000 >381 2003-12-03 10:45:00.000 2003-12-03 13:49:00.000 >382 2003-12-03 16:21:00.000 2003-12-03 16:21:00.000 >382 2003-12-03 16:20:00.000 2003-12-03 16:21:00.000 >383 2003-12-05 16:51:00.000 2003-12-12 16:40:23.550 >383 2003-12-05 16:50:00.000 2003-12-05 16:51:00.000