如何更新此表格的范围字段
(不要介意上面范围内的'1'值,它应该是 NULL )
使用下表中的Range值
当我内部将表与另一个加入他们的EquipmentCode时,值会加倍,如下所示:
这是我使用的查询:
SELECT
C.*,
R.Range AS RangeFromOtherTable
FROM
EquipmentCalibrationRef AS C
INNER JOIN
Range AS R
ON
R.EquipmentCode = C.EquipmentCode
答案 0 :(得分:0)
首先,您可以使用以下语句获取伪1对1匹配
SELECT ecr.*, r.[Range]
FROM EquipmentCalibrationRef ecr
INNER JOIN (
SELECT RefNo = ROW_NUMBER() OVER (PARTITION BY EquipmentCode ORDER BY [Range]), *
FROM [Range] r
) r ON r.RefNo = ecr.RefNo AND r.EquipmentCode = c.EquipmentCode