我有一个select语句,我希望根据表中的其他值计算立方体积。但是我想检查pr.Length_mm或pr.Width_mm或pr.Height_mm先前是否为NULL。我查看了CASE语句,但它似乎只能一次评估一列。
SELECT
sa.OrderName,
sa.OrderType,
pr.Volume_UOM
,pr.Length_mm*pr.Width_mm*pr.Height_mm AS Volume_Cubic
,pr.Length_mm*pr.Width_mm AS Volume_Floor
,pr.Length_mm
,pr.Height_mm
,pr.Width_mm
FROM CostToServe_MCB.staging.Sale sa
LEFT JOIN staging.Product pr
ON sa.ID = pr.ID
答案 0 :(得分:2)
SELECT pr.Volume_UOM
,pr.Length_mm*pr.Width_mm*pr.Height_mm AS Volume_Cubic
,pr.Length_mm*pr.Width_mm AS Volume_Floor
,pr.Length_mm
,pr.Height_mm
,pr.Width_mm
FROM CostToServe_MCB.staging.Sale sa
LEFT JOIN staging.Product pr
ON sa.ID = pr.ID
and pr.Length_mm is not null
and pr.Width_mm is not null
and pr.Height_mm is not null
答案 1 :(得分:2)
SELECT pr.Volume_UOM
,pr.Length_mm*pr.Width_mm*pr.Height_mm AS Volume_Cubic
,pr.Length_mm*pr.Width_mm AS Volume_Floor
,pr.Length_mm
,pr.Height_mm
,pr.Width_mm
FROM CostToServe_MCB.staging.Sale sa
LEFT JOIN staging.Product pr ON sa.ID = pr.ID
where pr.Length_mm is not null and pr.Width_mm is not null and pr.Height_mm is not null
答案 2 :(得分:0)
where pr.Length_mm is not null
and pr.Width_mm is not null
and pr.Height_mm is not NULL