SELECT COUNT(a.running_ID)
,a.operation_name
,a.return_Code
FROM log_master_2may_q9 a
,log_detail_2may_q9 b
WHERE a.execution_id = b.execution_id
AND b.type = 'MSISDN'
AND operation_name IN ( 'manageProfile', 'getPayment' )
GROUP BY a.return_Code
,a.operation_name;
在这里发生的事情是我从Multiples返回代码获取数据,如'101','102','902',这是失败和返回代码'100'和'S'是为了成功。
每次使用return_Code我都会得到一些数据。
现在我想要的是为失败代码找到的集体数据,对于成功代码也是如此。
我尝试使用Concat命令进行上述查询,但收到错误。
有人可以帮忙吗?
其他信息:
数据来自多个表格。
输出结果如下:
计数(A.running_ID)operation_name record_code 765 getPayment 102 14 ManageProfile 102 10 getPayment 902 661 ManageProfile S. 262 ManageProfile 100 11737 getPayment 100 20 getPayment 101
答案 0 :(得分:0)
SELECT
Sum(case When a.return_Code = '101' then 1 end) Code101Total,
Sum(case When a.return_Code = '102' then 1 end) Code102Total,
Sum(case When a.return_Code = '902' then 1 end) Code902Total,
Sum(case When a.return_Code = '100' then 1 end) Code100Total,
Sum(case When a.return_Code = '100' then 1 end) Code100Total,
Sum(case When a.return_Code In ('101', '102', '902') then 1 end) Fails,
Sum(case When a.return_Code = '100' then 1 end) SuccessesTotal
FROM log_master_2may_q9 a
join log_detail_2may_q9 b
on b.execution_id = a.execution_id
WHERE b.type = 'MSISDN'
AND operation_name IN ( 'manageProfile', 'getPayment' )
GROUP BY a.return_Code