Home > SQL > Update statment using Joins

Update statment using Joins

update t1
set t1.totalHrsWorked=cast(DATEDIFF(MINUTE , t2.startDate, t2.endDate) *0.0166667 AS decimal(10,2))
from Table1 t1
inner join Table2 t2
on t1.Id = t2.Id
where t1.Id between 1 and 100

Advertisements
Categories: SQL
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: