我想在 U-SQL 中的if else条件中对两个不同的列使用Null检查和0检查。但它给我带来了错误。我猜它没有采用Null检查表达式来检查0值。
@ctetemp=
SELECT
gvo.TcontainerUnitno,
gvo.TcontainerETD,
(gvo.TlotMeasurement IS NULL || cte1.SumTlotMeasurement== 0 ) ?
( 1.0 / (cte1.NumberOfShipments == 0 ? 1 : cte1.NumberOfShipments)) :
(gvo.TlotMeasurement / cte1.SumTlotMeasurement) AS ConVolPct
FROM @GvoFinal AS gvo
INNER JOIN @cte AS cte1
ON
gvo.Tcontainerunitno = cte1.UnitNumber
AND gvo.TcontainerETD = cte1.TcontainerETD
欣赏是否快速回答。
答案 0 :(得分:1)
那里需要一个有效的.NET表达式。所以试试这个:
(gvo.TlotMeasurement == null|| cte1.SumTlotMeasurement== 0 ) ?
( 1.0 / (cte1.NumberOfShipments == 0 ? 1 : cte1.NumberOfShipments)) :
(gvo.TlotMeasurement / cte1.SumTlotMeasurement) AS ConVolPct