Skip to content
Advertisement

Update same table as selected with calculated values using resultset

I’m new to sql (scripting). Single CRUD commands are no problem, but I’m trying to create a stored procedure that wil update a table with a calculated value using the results from the same selected table.

In the table there is a value with the total vacation-hours for each employee and a value of the remainder of the vaction-hours of the last year.

What I will try to achieve is to ADD the new hours for this year to the remaining hours. There is one catch. The new hours column is in whole hours, the remaining-hours is a value in ‘ticks’ which is hundred nanoseconds.

How can I update the table using the same table as a reference for this calculation?

Advertisement

Answer

You can then do the same after including JOINS and WHERE clauses…

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement