oracle sql-替换值

select name,count(case),starttime, endtime 
from employee 
where team in  ('dba','spt','sd') and name in 
(('dba1','db2','db3','spt1','spt2','sd1','sd2') 
and starttime between sysdate - 3 and sysdate ;

当我运行此查询时,我得到以下输出,其中用户spt1最近三天没有任何数据,因此其结果未显示

dba1 12 23 42
dba2 14 12 15
dba3 23 11 23
spt2 53 23 43
sd1  40 34 23
sd2  98 34 23

但我需要得到如下结果

dba1 12 23 42
dba2 14 12 15
dba3 23 11 23
spt1 -  -  -
spt2 53 23 43
sd1  40 34 23
sd2  98 34 23

有什么方法可以得到这个结果?

评论
  • DJHongKong
    DJHongKong 回复

    尝试以下

    select 
        e1.name,
        count(e1.case),
        e1.starttime, 
        e1.endtime 
    from employee e1
    left join employee e2
    where e2.team in  ('dba','spt','sd') and e1.name in 
    (('dba1','db2','db3','spt1','spt2','sd1','sd2') 
    and e1.starttime between e1.sysdate - 3 and e1.sysdate ;