Select returns users locked or a default value for null rows I'm don't have much knowlegde on Oracle database and used some questions from here to obtain this query:

select case when ((sysdate - timestamp)*24 &lt; 1 and returncode &lt;&gt; 0) then 

(username  || '@' || userhost|| ' ON ' || to_char(timestamp,'DD-MON-YYYY HH24:MI:SS')|| ' FAILED AT ' || action_name || ' BECAUSE ' || returncode || decode(returncode,'28000',':Maximum Login Attempt','1004',':Wrong Connection','1005',':NULL Password','1017',':Wrong Password','1045',':Insufficient Priviledge','0',':Login Accepted',':Unkown Code')) 

else 'none' 

end as "locked users" from sys.dba_audit_session where (sysdate - timestamp)*24 &lt; 1 and returncode &lt;&gt; 0 order by timestamp;


With this query, I want to retrieve users locked on which date and what causes the lock, if there's no users, returns only 'none' instead of "no rows selected". For users locked it works, but the else statement don't. Can someone explain me why? I need this to fix my zabbix database monitoring with ODBC.
Just select the union of the query and the 'none' constant if the original query does not return any row:

with s as (
select case when ((sysdate - timestamp)*24 &lt; 1 and returncode &lt;&gt; 0) then 
(username  || '@' || userhost|| ' ON ' || to_char(timestamp,'DD-MON-YYYY HH24:MI:SS')|| ' FAILED AT ' || action_name || ' BECAUSE ' || returncode || decode(returncode,'28000',':Maximum Login Attempt','1004',':Wrong Connection','1005',':NULL Password','1017',':Wrong Password','1045',':Insufficient Priviledge','0',':Login Accepted',':Unkown Code')) 
else 'none' 
end as "locked users" from sys.dba_audit_session where (sysdate - timestamp)*24 &lt; 1 and returncode &lt;&gt; 0 order by timestamp
)
select 'none' as "locked_users" from dual where not exists (select * from s)
union all
select * from s;