Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Replace column data with column data of another table Expand / Collapse
Author
Message
Posted Saturday, April 20, 2013 6:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, April 25, 2013 4:17 AM
Points: 2, Visits: 6
I have Two tables as follows

Table A:
Empid WeekoffDate
1000 2012-04-07 00:00:00.000
1000 2012-05-17 00:00:00.000
1000 2012-06-07 00:00:00.000

Table B:
Empid WeekoffChangeDate WeekoffDate
1000 2012-05-15 00:00:00.000 2012-05-17 00:00:00.000
1000 2012-06-13 00:00:00.000 2012-06-07 00:00:00.000


Result Table:
Empid ActualWeekOffDate
1000 2012-04-07 00:00:00.000
1000 2012-05-15 00:00:00.000
1000 2012-06-13 00:00:00.000

I need the above result table, I had tried joins and union all but did not get the result.


Thanks in advance.




Post #1444704
Posted Saturday, April 20, 2013 7:56 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 3:09 AM
Points: 1,913, Visits: 19,470
one way to consider

SELECT   
A.Empid,
ISNULL(B.WeekoffChangeDate, A.WeekoffDate) AS ActualWeekOffDate
FROM Table_A AS A
LEFT OUTER JOIN Table_B AS B ON A.WeekoffDate = B.WeekoffDate
AND A.Empid = B.Empid




______________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Post #1444713
Posted Thursday, April 25, 2013 3:17 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, April 25, 2013 4:17 AM
Points: 2, Visits: 6
Thank you very much.. it worked out for me
Post #1446365
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse