Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 JOIN tow SQL tables

Author  Topic 

laddu
Constraint Violating Yak Guru

332 Posts

Posted - 2011-04-28 : 10:28:52
need help to write a query to pull the below data

difference between
RIinvitationCreatedDate in RInvitation table
and UsertRegistrationCompletedDate from User table

and Join these two tables with RInvitation.RInvitationLoginID on User.UserID

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-28 : 10:41:15
You've almost said it

select u.UserID, u.UsertRegistrationCompletedDate - r.RIinvitationCreatedDate
from RInvitation r
join User u
on u.UserID = r.RInvitationLoginID


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

laddu
Constraint Violating Yak Guru

332 Posts

Posted - 2011-04-28 : 11:16:47
Thank you,

actually I am looking the difference in minutes,
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-28 : 11:20:58
select u.UserID, datediff(mi,r.RIinvitationCreatedDate ,u.UsertRegistrationCompletedDate)
from RInvitation r
join User u
on u.UserID = r.RInvitationLoginID

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -