sql - Can I avoid doing this Row by Row -


if have 2 tables columns shown below. want fill in actualstart , actualend times based on earliest , latest times scanned within shift.

is there way in linq or set based way in sql?

currently intend use cursor , go through each row in usersshifts earliest , latest fingerprint scan times within user's shift , update actualstart , actualend columns

usersshifts

  • usersshiftsid
  • userid
  • shiftstart
  • shiftend
  • actualstart
  • actualend

fingerprintscan

  • userid
  • scannedtime

you can in sql adding time constraint join:

select      us.usersshiftsid,     us.userid,     us.shiftstart,     us.shiftend,     min(fs.scannedtime) actualstart,     max(fs.scannedtime) actualend usersshifts left join fingerprintscan fs     on us.userid = fs.userid     , fs.scannedtime between us.shiftstart , us.shiftend  group     us.usersshiftsid,     us.userid,     us.shiftstart,     us.shiftend 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -