oracle sql

hello experts,
how can I limit display in my sql. I have a table which displays multiple values for a key value. I want to display only one key value and multiple non-key values in my output. here is what I want to display --

column_1                                   column_2
__________________________________________
hostname1                                i/p1
                                                    i/p2
                                                    i/p3
hostname2                               i/p1
                                                    i/p2
                                                    i/p3
                                                    i/p4
                                                    i/p5
hostname3                                i/p1
hostname4                                i/p1
                                                     i/p2
                                                      .
                                                      .
.
.
 and so on.
smaligAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

awking00Commented:
>>here is what I want to display<<
And what values are you starting with? Are they like this?
hostname1      i/p1
hostname1      i/p2
hostname1      i/p3
hostname2      i/p1
hostname2      i/p2
hostname2      i/p3
hostname2      i/p4
hostname2      i/p5
hostname3      i/p1
hostname4      i/p1
hostname4      i/p2
.
.
.
etc.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you can do that indeed with a inline query, though normally this should be done in a reporting tool.;
select case when rn = 1 then column1 end column1
  , column2
 from ( select column1, column2, row_number() over (partition by column1 order by column2) rn
          from yourtable
     ) sq
order by column1, rn

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Commented:
If so,
select decode(rn,1,column_1) column_1, column_2 from
(select column_1, column_2,
 row_number() over (partition by column_1 order by column_2) rn
 from tab1);
0
awking00Commented:
Sorry, didn't see the post from angelIII before I submitted.
0
Steve WalesSenior Database AdministratorCommented:
Guy's answer pretty much sums it up ...

But for learning the tools available to you, you can do this in SQLPlus by entering the BREAK command:

break on column_1
select column_1, column_2 from table order by column_1, column_2

You can clear your breaks by "clear breaks"

Refer to the Documentation for all formatting options available to you:
http://docs.oracle.com/database/121/SQPUG/ch_six.htm#i1081008
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.