Your intention is to return 'Y' if there is any row in session_roles with role = 'DBA', otherwise 'N'. The syntax you posted is off. Here are clean options for Oracle:
Simple and idiomatic: SELECT CASE WHEN EXISTS (SELECT 1 FROM session_roles WHERE role = 'DBA') THEN 'Y' ELSE 'N' END AS has_dba FROM DUAL;
If you really want to use CONCAT (Oracle CONCAT takes exactly two arguments, so this is a bit silly but valid): SELECT CONCAT( CASE WHEN EXISTS (SELECT 1 FROM session_roles WHERE role = 'DBA') THEN 'Y' ELSE 'N' END, '' ) AS has_dba FROM DUAL;
Notes:
- EXISTS returns true if the inner query finds any row; Oracle then yields 'Y' or 'N'.
- The DUAL table is used to return a single row result.