我想知道是否有可能加入腸子上的greates值。INNER JOIN上最大的價值
因此,例如
SELECT *
FROM Vehicle v
INNER JOIN VehicleCost vc ON v.VehicleWeight > vc.WeightFrom AND c.VehicleWeight < vc.WeightTo
但如果v.VehicleWeightTotal> v.VehicleWeight我想,要更換v.VehicleWeight的內連接。所以這可能對每輛車都是不同的加入。
我怎麼會去這樣做內加入該檢查?
樣品:
tblVehicle
VehicleId VehicleWeight VehicleWeightTotal
1 12 15
2 1 8
3 16 20
tblVehicleCost
WeightFrom WeightTo Dollars
0 5 1
6 11 8
12 16 9
17 20 15
所以:
Vehicle 1 = 9
Vehicle 2 = 8
Vehicle 3 = 15
請顯示一些示例數據和預期結果。一般來說,將邏輯放入連接並不是一個好主意。 – HLGEM
已添加詳細信息 – mameesh