select to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') as 日期,count( case when appeal_type = 1 and substr(gmt_create, 1, 10) = to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then 1 else null end ) as 钱货一方当日发起数 , count(case when appeal_type = 2 and substr(gmt_create, 1, 10) = to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then 1 else null end ) as 判决不满意当日发起数, count(case when substr(gmt_create, 1, 10) <= to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') and status not in (9,10) and appeal_type=1 then 1 else null end ) as 钱货一方积压量, count(case when substr(gmt_create, 1, 10) <= to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') and status not in (9,10) and appeal_type=2 then 1 else null end ) as 判决不满意积压量, count(case when status = 9 and appeal_type = 1 and substr(gmt_modified, 1, 10) = to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then 1 else null end ) as 钱货一方申诉成功数, count(case when status in (9,10) and appeal_type = 1 and substr(gmt_modified, 1, 10) =to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then 1 else null end ) as 钱货一方当日完结数, count(case when status = 9 and appeal_type = 2 and substr(gmt_modified, 1, 10) =to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then 1 else null end ) as 判决不满意当日申诉成功数, count(case when status in (9,10) and appeal_type = 2 and substr(gmt_modified, 1, 10) =to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then 1 else null end ) as 判决不满意当日完结数, avg( case when status in (9,10) and appeal_type=1 and substr(gmt_modified, 1, 10) = to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then datediff(to_date(gmt_modified,'yyyy-MM-dd HH:mi:ss') ,to_date(gmt_create,'yyyy-MM-dd HH:mi:ss') ,'hh') else null end) as 钱货一方当日完结的平均时间, avg( case when status in (9,10) and appeal_type=2 and substr(gmt_modified, 1, 10) = to_char(dateadd(getdate(), -1, 'dd'), 'yyyy-mm-dd') then datediff(to_date(gmt_modified,'yyyy-MM-dd HH:mi:ss') ,to_date(gmt_create,'yyyy-MM-dd HH:mi:ss') ,'hh') else null end) as 判决不满意当日完结的平均时间 from 某个表 where ds= to_char(dateadd(getdate(), -1, 'dd'), 'yyyymmdd') and buyer_nick !='c测试账号925'