Friday, 23 August 2013

SQL*PLUS Concatenation Issues

SQL*PLUS Concatenation Issues

This is for SQL*PLUS
I have a table "Patient" which has 5 fields.
CREATE TABLE PATIENT
(PAT_ID CHAR (4) PRIMARY KEY,
PAT_NAME VARCHAR (7),
ADMITTED DATE,
ROOM CHAR (3),
DOCTOR VARCHAR (7));
INSERT INTO PATIENT VALUES
(1001, 'FRED', '30-MAR-07', 101, 'PAYNE');
I want to create a view where my output to look like this:
Patient Doctor Room Admitted
"-----------------------------------------------"
1001 Fred Payne 101 March 31, 2007
The problem is that I want to concatenate Pat_name and Pat_ID into their
own separate "Patient" column but ALSO have the other three fields also
concatenated with it(notice there is no separation in the 'dashes').
Basically, I have 5 fields. For simplicity's sake, let's call them fields
"1, 2, 3, 4, 5".
I want to combine ALL of them together, but FIRST, I need to combine
fields 1 and 2. This small column (fields 1 and 2 combined) will be called
"Patient". THEN, I need to concatenate fields 3, 4, and 5 WITH my Patient
column so that all 5 fields are now concatenated together but with only 4
headings.

No comments:

Post a Comment