現在我想對列中包含值或不爲空的行進行計數。我是SQL的初學者;我的SQL查詢如下:Sql計數包含一些值的行
select count(news) AS news_count, count(`msg`) as msg_count , count('req') as req_count
from news_msg_activity
where news!=''
UNION
select count(news) AS news_count, count(`msg`) as msg_count , count('req') as req_count
from news_msg_activity
where msg!=''
UNION
select count(news) AS news_count, count(`msg`) as msg_count , count('req') as req_count
from news_msg_activity
where req!=''
當我運行查詢時,它給出了兩個數字的結果。但是我需要一個單一的數字結果來計算上述操作記錄的數量。我不知道如何編寫該查詢。有誰能夠幫助我?
,但我需要一個像
news_count || msg_count || req_count
2 || 2 || 3
需要更清楚 – 2015-04-03 13:18:59
謝謝..現在正在工作 – 2015-04-03 13:30:31