如果只是缺少个别指标,完全可以参照楼上的Union all
如果缺少的指标比较多,则建议用创造编码表的方式解决
创建编码表t1
id name
1 80-90
2 70-80
3 <60
select t1name, nvl(t2user_count, 0)
from t1,
(select case
when cj > 80 and cj <= 90 then
'1'
when cj > 70 and cj <= 80 then
'2'
when cj > 70 and cj < 60 then
'3'
else
null
end id,
count(distinct 学生ID) user_count
from 成绩表) t2
where t1id = t2id(+)
用nvl函数吧,nvl(xxx,0)------如果为空的话就为0(当然你也可以用其他数字或者字符来表示),不是空的话,就直接显示xxx,
to_number(nvl(xxx,0))--------完整就这么用,为空时就显示0
您好,提问者:
1、我看你是用了decode函数做判断的,既然显示字段是固定的,那么就可以decode函数。
2、另外如果涉及左右连接,那么也可以采取left
join
和
right
join来进行 *** 作。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)