select * from (
select count(1) from pf_company_info where delete_flag = 0 and cate_one = 2 and cate_two like '%201%'
UNION ALL
select count(1) from pf_company_info where delete_flag = 0 and cate_one = 1 and cate_two like '%102%'
UNION ALL
select count(1) from pf_company_info where delete_flag = 0 and cate_one = 3 and cate_two like '%301%'
)a
现在的结果是
count
89
0
0
我想变成
count1 count2 count
89 0 0
请求大佬帮忙!
如下:
select (
select count(1) from pf_company_info where delete_flag = 0 and cate_one = 2 and cate_two like '%201%'
) as count1,(
select count(1) from pf_company_info where delete_flag = 0 and cate_one = 1 and cate_two like '%102%'
) as count2,(
select count(1) from pf_company_info where delete_flag = 0 and cate_one = 3 and cate_two like '%301%'
) as count3
from dual;
select * from (select count(1) from pf_company_info where delete_flag = 0 and cate_one = 2 and cate_two like '%201%') count1,
(select count(1) from pf_company_info where delete_flag = 0 and cate_one = 1 and cate_two like '%102%') count2,
(select count(1) from pf_company_info where delete_flag = 0 and cate_one = 3 and cate_two like '%301%') count