How do you replace nulls in a crosstab query with zeroes?

前端 未结 1 1327
星月不相逢
星月不相逢 2021-01-24 09:42

Based on the following SQL in Access...

TRANSFORM Sum([Shape_Length]/5280) AS MILES
SELECT \"ONSHORE\" AS Type, Sum(qry_CurYrTrans.Miles) AS [Total Of Miles]
FRO         


        
相关标签:
1条回答
  • 2021-01-24 10:34

    I think you have to use the Nz function, which will allow you to convert NULLs to another value. In this case, I used the (optional) part of the function to say, "If Sum([Shape_Length]/5280) is NULL, set it to 0". You may have to use quotes around the 0, I can't recall.

    TRANSFORM Nz(Sum([Shape_Length]/5280), 0) AS MILES
    SELECT "ONSHORE" AS Type, Sum(qry_CurYrTrans.Miles) AS [Total Of Miles]
    FROM qry_CurYrTrans
    GROUP BY "ONSHORE"
    PIVOT qry_CurYrTrans.QComb IN ('1_HCA_PT','2_HCA_PT','3_HCA_PT','4_HCA_PT'); 
    
    0 讨论(0)
提交回复
热议问题