April 20, 2013 at 6:27 am
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.
April 20, 2013 at 7:56 am
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
April 25, 2013 at 3:17 am
Thank you very much.. it worked out for me
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply