contract rec # state dealer coverage
-------- --- ---- ----- ------ --------
55661 1 YUFL FL GP GP15
55661 2 YUFL FL GP
55662 1 YUFL FL GP GP16
55662 2 YUFL FL GP
REC'2'的覆盖范围字段为空。如何用REC'1'用相同的合同#填充覆盖范围字段中的相同数据?表名:contract_ex
即。
55661 REC'2' coverage s/b GP15
55662 REC'2' coverage s/b GP16
答案 0 :(得分:2)
试试这个:
SELECT contract,
rec,
state,
dealer,
(SELECT coverage FROM YourTable
WHERE contract = T.contract AND rec = 1) coverage
FROM YourTable T