【发布时间】:2012-04-18 10:10:58
【问题描述】:
我想获取 2 列计数并将它们的总数作为一个新列。 我该怎么做?
我写了这个查询,但是返回的总数是错误的。
SELECT count(case when `status`='1' then 1 else 0 end) AS HOT,
count(case when `status`='5' then 1 end)
AS Special_Case,count(case when 1=1 then 1 end) AS TOTAL
FROM `tbl_customer_conversation` group by
date(`dt_added`),user_id
【问题讨论】:
-
do their total as new column是什么意思? -
HOT 和 Special_Case 中提取的数字总数
-
case when 1=1 then 1 end将始终返回一个.. -
是的,但我想计算 HOT 和 Special_Case 的数量,然后是总数