1、条件函数case when
用于where条件查询中
where a.project_id = b.project_id
and a.project_id = c.project_id
and c.COMPANY_NAME like '%南区%'
and (case
when '73C3E003F36AE50BA252EA82B02A35926CD90FC7EB0A3B8F' is null then
'73C3E003F36AE50BA252EA82B02A35926CD90FC7EB0A3B8F'
else
'1'
end)=c.project_name
2、查询本年到现在月份
select to_char(add_months(start_date, level ), 'yyyymm') stat_date
from (select add_months(trunc(sysdate, 'y'), 0) as start_date,
trunc(sysdate, 'mm') as end_date
from dual)
connect by level < = months_between(end_date, start_date)