SQL语句的Count函数用法和字符串拼接

2025-02-23 19:47:24
推荐回答(3个)
回答1:

select '当前任务总数:'+count(*) +',其中'+sum(case when 任务状态='未处理' then 1 else 0 end) +'未处理,' + sum(case when 任务状态='处理中' then 1 else 0 end) +'处理中'

from 表名

回答2:

select count(1), 任务状态 from table grounp by 任务状态,这样不就出现一个结果集,两条记录 1: 15 未处理;2:1 正处理。至于输出么,你自己组装好了!

回答3:

select '当前任务总数:'||count(*)||',其中'||sum(case when 任务状态='未处理' then 1 else 0 end)||'个未处理,'||sum(case when 任务状态='处理中' then 1 else 0 end)||'个正在处理中'
from table1