Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Query to get output

RAMJANESep 9 2014 — edited Sep 9 2014

Hi All,

I am trying to write a query to get output in specific format. I have 3 different table to get this data. I can get multiple rows but output should be based on B_TYPE and should return result in one row only.

I want out put to be look like

A_NUM     B_FCODE as PCode      C_Description as PDesc     B_FCODE as CCode     C_Description as CDesc     B__FCode as RCode     C_Description as RDesc

WA-1001     DRG                              Do rough gricing               OTH                              Others                              NON                              No other noise

Below is DDL & DML for test data.

create table A
(
A_NUM VARCHAR2(20) ,
A_FCODE VARCHAR2(20)
);

INSERT INTO A VALUES ('WA-1001','DRG');

CREATE TABLE B
(
B_NUM VARCHAR2(20),
B_TYPE VARCHAR2(20),
B_FCODE VARCHAR2(20)
);

INSERT INTO B VALUES ('WA-1001','P','DRG');

INSERT INTO B VALUES ('WA-1001','C','OTH');

INSERT INTO B VALUES ('WA-1001','R','NON');

CREATE TABLE C
(
C_FCODE VARCHAR2(20),
C_DESCIPTION VARCHAR2(20)
);

INSERT INTO B VALUES ('DRG','Do rough gricing');

INSERT INTO B VALUES ('OTH', 'Others');

INSERT INTO B VALUES ('NON', 'No other noise');

Thanks in advance.

AR

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2014
Added on Sep 9 2014
1 comment
425 views