一个查询输出
"MAO" "5"
"ADA_REGULAR" "1"
"JDA_REGULAR" "1"
"SR_ASST_SRC" "2"
"SUPDT_SRC" "1"
"AO_SRC" "3"
"ADA_SRC" "2"
"DDA_SEEDS" "2"
"JDA_SEEDS" "2"
"ADDDIR_SEEDS" "2"
第二次查询输出
"MAO" "4"
"ADA_REGULAR" "3"
"AO Tech" "3"
"JDA_REGULAR" "3"
我想要输出,就像这样。
column_name no.of_days no.of_days
"MAO" "5" 4
"ADA_REGULAR" "1" 3
"JDA_REGULAR" "1" 3
"SR_ASST_SRC" "2" 0
"SUPDT_SRC" "1" 0
"AO_SRC" "3" 0
"ADA_SRC" "2" 0
"DDA_SEEDS" "2" 0
"JDA_SEEDS" "2" 0
"ADDDIR_SEEDS" "2" 0
"AO Tech" 0 3
enter code here
答案 0 :(得分:0)
您可以尝试对输出使用联合以获取所需的所有列名,并在查询结果的左侧将其联接到查询输出以获取第一个和第二个ooutput的日期
select t1.column_name, ifnull(t2.num_days,0), ifnull(t3.num_days,0)
from (
select column_name
from // your query for output 1
union
select column_name
from // your query for output 2
) t1
left join (
// your query for output 1
select column_name, num_days
from my_table1
) t2 ON t1.column_name = t2.column_name
left join (
// your query for output 2
select column_name, num_days
from my_table1
) t3 ON t1.column_name = t3.column_name