这是 T-SQL - 不确定您正在运行什么,请将其作为标签添加到您的问题中以获得更好的答案 - 在编辑 OP 之前编写此代码,因此请仔细检查 cols。
根据 x-zeros 的评论编辑
SELECT B.CUSTOMER,S.SKU,B.ORDERDATE,S.Amt
FROM TABLE_B B
INNER JOIN
( SELECT C.SKU,C.OFFERDATE,C.Amt,
ROW_NUMBER() OVER (PARTITION BY C.SKU ORDER BY C.OFFERDATE DESC) X
FROM TABLE_A C
)S ON S.X = 1 AND B.SKU = S.SKU
ORDER BY B.CUSTOMER
CREATE TABLE TABLE_A
(SKU varchar(8), OfferDate Date, Amt int)
INSERT INTO TABLE_A
VALUES('AAA', '2012-01-15', 22),
('AAA' ,'2012-02-23', 24),
('AAA' ,'2012-03-31', 25),
('AAA' ,'2012-05-20', 28),
('BBB','2011-01-15 00:00:00.000', 33),
('BBB','2011-02-23 00:00:00.000', 35),
('BBB','2011-03-31 00:00:00.000', 36),
('BBB','2011-05-20 00:00:00.000', 39),
('CCC', '2012-01-15', 43),
('CCC' ,'2012-02-23', 45),
('CCC' ,'2012-03-31', 47),
('CCC' ,'2012-04-18', 44)
CREATE TABLE TABLE_B
(CUSTOMER varchar(8),SKU varchar(8), OrderDate Date)
INSERT INTO TABLE_B
VALUES('A001','AAA','2012-02-01'),
('B001','AAA','2012-04-10'),
('C001','AAA','2012-05-31'),
('A001','BBB','2011-02-01'),
('B001','BBB','2011-04-10'),
('C001','BBB','2011-05-31'),
('B001','CCC','2011-04-10'),
('C001','CCC','2011-05-31')