Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Siddhartha.

Asked: July 06, 2016 - 8:41 am UTC

Last updated: July 06, 2016 - 11:35 pm UTC

Version: 11g

Viewed 1000+ times

You Asked

c d f
---- ---- ----
1 a 100
1 b 200


Output:
1 a 100 b 200


and Chris said...

Come on, help us out a little! What's the story? What exactly are you trying to do here?

And please provide sample data in the form of create table + inserts!

Anyway, based on what you've provided I'm guessing you want a pivot along the lines of:
create table t (
  a int,
  b varchar2(1),
  c int
);

insert into t values (1, 'a', 100);
insert into t values (1, 'b', 200);

select * from t
pivot (
  min(b) as b, min(c) as c 
  for (b) in ('a' as a, 'b' as b)
);

A  A_B  A_C  B_B  B_C  
1  a    100  b    200 

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Waste of your time

John Gasch, July 06, 2016 - 4:49 pm UTC

Chris - Why do you bother to waste your valuable time responding to such incomplete inquiries? The submitter is disrespectful and unappreciative of the service you provide.

The rest of us appreciate you and Connor taking over this task from Tom.
Chris Saxon
July 06, 2016 - 11:35 pm UTC

My temptation was to answer it as:

select '1 a 100 b 200 ' from dual

:-)

Cheers,
Connor

Seriously?

Ravi B, July 06, 2016 - 4:58 pm UTC

Seriously? That is the question Siddhartha? Chris, hats off!