Skip to Main Content

Breadcrumb

more

Connor and Chris don't just spend all day on AskTOM. You can also catch regular content via Connor's blog and Chris's blog. Or if video is more your thing, check out Connor's latest video and Chris's latest video from their Youtube channels. And of course, keep up to date with AskTOM via the official twitter account.

Question and Answer

Chris Saxon

Thanks for the question, Siddhartha.

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

Answered by: Chris Saxon - Last updated: July 06, 2016 - 11:35 pm UTC

Category: Database - Version: 11g

Viewed 1000+ times

Whilst you are here, check out some content from the AskTom team: NULL's vs NOT NULL's and Performance

You Asked

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


Output:
1 a 100 b 200


and we 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 

and you rated our response

  (2 ratings)

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

Reviews

Waste of your time

July 06, 2016 - 4:49 pm UTC

Reviewer: John Gasch from Greenbelt MD

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

Followup  

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?

July 06, 2016 - 4:58 pm UTC

Reviewer: Ravi B from Bay Area, CA

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