DECLARE @t1 TABLE(num INT)
DECLARE @t2 TABLE(num INT, [date] NVARCHAR(5), amount INT)
INSERT INTO @t1 (num) VALUES (1),(2),(3)
INSERT INTO @t2 (num,[date],amount) VALUES (1,'12/31',30)
INSERT INTO @t2 (num,[date],amount) VALUES (1,'12/30',31)
INSERT INTO @t2 (num,[date],amount) VALUES (1,'12/29',20)
INSERT INTO @t2 (num,[date],amount) VALUES (2,'12/31',100)
INSERT INTO @t2 (num,[date],amount) VALUES (2,'12/30',90)
INSERT INTO @t2 (num,[date],amount) VALUES (3,'12/31',12)
INSERT INTO @t2 (num,[date],amount) VALUES (4,'11/01',1)
SELECT t2.num,t2.[date],amount
FROM @t1 t1 JOIN @t2 t2 ON t1.num = t2.num
WHERE t2.[date] in (
SELECT MAX(t3.[date])
FROM @t2 t3
WHERE t3.num = t2.num
)
ORDER BY t2.num