I'm new to sql and I'm writing a sql script to select data and the results will be displayed in a .csv format. For one of the fields, I'm needing to select only what is before the @ in the email address for everyone in the listing. I'm not wanting to update the records in the table.
Ex: john.doe@yahoo.com
I'm only needing to select the john.doe
I need assistance please in doing this. I'm using sqlplus in a Linux environment.
Here's now what I have as part of the script. I still need assistance with getting the desired output.
(select nvl(c.email_email_address, ' ')
from email c, person a
where c.email_pidm = a.person_pidm and
PERSON.ID = a.person_id and
c.email_emal_code = 'EMPL' and
c.email_status_ind = 'A' and
c.rowid = (select max(b.rowid)
from email b
where b.email_pidm = a.person_pidm and
b.email_emal_code = 'EMP'
and b.email_status_ind = 'A')
) "Employee_Email_Address",
SELECT SUBSTR(email_email_address, 0, INSTR(email_email_address, '@')-1)
--(select nvl(c.email_email_address, ' ')
from email c, person a
where c.email_pidm = a.person_pidm and
PERSON.ID = a.person_id and
c.email_emal_code = 'EMP' and
c.email_status_ind = 'A' and
c.rowid = (select max(b.rowid)
from email b
where b.email_pidm = a.person_pidm and
b.email_emal_code = 'EMPL'
and b.email_status_ind = 'A')
) "Username"