SELECT *
FROM goodluck AS A
WHERE A.TBEL_ID IN
(
SELECT TOP 1 B.TBEL_ID
FROM CG_TB_ExtendLog AS B
WHERE A.TBEL_TBEU_ID = B.TBEL_TBEU_ID
AND A.TBEL_IP = B.TBEL_IP
AND Year(A.TBEL_Time) = Year(B.TBEL_Time)
AND Month(A.TBEL_Time) = Month(B.TBEL_Time)
AND Day(A.TBEL_Time) = Day(B.TBEL_Time)