SQL Language (MOSC)

MOSC Banner

select query with additional record

edited Oct 25, 2016 5:00AM in SQL Language (MOSC) 5 commentsAnswered

Hello,

I have a table like below with few records.

create table dept(

  deptno number(2,0),

  dname  varchar2(14),

  loc    varchar2(13),

  constraint pk_dept primary key (deptno)

);

insert into dept

values(10, 'ACCOUNTING', 'NEW YORK');

insert into dept

values(20, 'RESEARCH', 'DALLAS');

insert into dept

values(30, 'SALES', 'CHICAGO');

insert into dept

values(40, 'OPERATIONS', 'BOSTON');

commit;

I need output like below using a single select statement without using UNION.

    10    ACCOUNTING      NEW YORK

    20    RESEARCH         DALLAS

    30    SALES                 CHICAGO

    40    OPERATIONS     BOSTON

    0      OTHER               OTHER

Any help is greatly appreciated.

Thanks

KK

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center