mardi 4 août 2015

SQL Server iterate in select query and update upon condition

I have the following result from query

empId   totalPoints  addPointsDate  incidentDate
-------------------------------------------------
 1           11        2015-06-04    2015-07-11
 2           12        2015-07-04    2015-08-16
 3           10        2015-08-04    2015-06-14
 4           9         2015-06-14    2015-09-11

I have to update the total points if the addPointsDate was 5 weeks ago and I didn't have any incidentDate during this period.

Can I do that with stored procedure or I have to use sql function

Aucun commentaire:

Enregistrer un commentaire