Reputation: 785
I am learning more in PL/SQL Toad for Oracle. I want to select some columns in 3 tables and then I use case statements to execute if it is Null or Not. This is my sample script.
SELECT (CASE WHEN a.column1 is NULL
THEN 'Active'
ELSE 'Inactive'
END) as Status_Define_Resources, <<some columns>>,
(CASE WHEN b.column1 is NULL
THEN 'ACTIVE'
ELSE 'INACTIVE'
END) as STATUS_USER, <<some columns>>,
c.LASTNAME, c.FIRSTNAME, c.MIDDLENAME
FROM table1 a, table2 b, table3 c
It is running.. my problem is I want to combine column names c.LASTNAME
, c.FIRSTNAME
and c.MIDDLENAME
any ideas? And sorry I am new in Toad for Oracle PL/SQL.
Upvotes: 1
Views: 388
Reputation: 1313
You can use Concatenation
. Here's a example.
But in your case
SELECT (CASE WHEN a.column1 is NULL
THEN 'Active'
ELSE 'Inactive'
END) as Status_Define_Resources, <<some columns>>,
(CASE WHEN b.column1 is NULL
THEN 'ACTIVE'
ELSE 'INACTIVE'
END) as STATUS_USER, <<some columns>>,
c.LASTNAME||','||c.FIRSTNAME||','||c.MIDDLENAME as "Complete Name"
FROM table1 a, table2 b, table3 c
I assume the 3 tables are related by a Foreign Key
then used Join Statements
Upvotes: 1