2016-09-20 58 views

回答

2

在SQL這將是

SELECT 
    SUM(CASE WHEN a is null then 1 else 0 end) as a_null_count, 
    SUM(CASE WHEN b is null then 1 else 0 end) as b_null_count,  
    --- ... 
    SUM(CASE WHEN z is null then 1 else 0 end) as z_null_count 
FROM table 
+0

有什麼辦法來避免鍵入每個列名? – user2205916

+0

@ user2205916 - 您可以使用元數據編寫查詢來生成sql語句。 - 從列視圖中選擇並創建彙總語句。 – Hogan

+0

'else 0'在這裏是不需要的case case – leftjoin