用於提取非空的所有列的計數的查詢;非空的所有列的計數
id | Col1 | Col2 | Col3 | Col4 |
--------------------------------
1 | abc | --- | xyz | pqr |
--------------------------------
2 | def | ghi | --- | pqr |
--------------------------------
3 | --- | --- | hgy | --- |
--------------------------------
4 | --- | jko | | uyi |
--------------------------------
SELECT COUNT(*) FROM table 1 WHERE Col1!='---'
SELECT COUNT(*) FROM table 1 WHERE Col2!='---'
SELECT COUNT(*) FROM table 1 WHERE Col3!='---'
在一個單一的查詢
如何獲得的結果作爲
-----------------------
Cnt1| Cnt2 |Cnt3| Cnt4|
-----------------------
2 | 2 | 2 | 3 |
-----------------------
請清理這個問題的格式:http://stackoverflow.com/editing-help – 2013-05-01 05:48:04