Home » SQL & PL/SQL » SQL & PL/SQL » Pivot Table (oracle 10)
Pivot Table [message #440660] Tue, 26 January 2010 09:13 Go to next message
tiagocscoelho
Messages: 3
Registered: October 2009
Location: madrid
Junior Member
Hi!

I'm with a problem to build a pivot table!
I've a query that returns something like

Column 1 | Column 2
name_1 | str 1
name 1 | str 2
name 2 | str 3
name 2 | str 4
name 3 | str 5

and i need something like

Name 1 | Name 2 | Name 3
str 1 str 3 str 5
str 2 str 4

Note that i never know, how many names or str value the query results can return, so i can not use the case function.

Any suggestion?


Thanks in advance

Re: Pivot Table [message #440674 is a reply to message #440660] Tue, 26 January 2010 10:18 Go to previous messageGo to next message
Michel Cadot
Messages: 63806
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Note that i never know, how many names or str value the query results can return, so i can not use the case function.

See the folowing topic, it will give different ways to do it:
http://www.orafaq.com/forum/t/154231/102589/

If you post a working Test case: create table and insert statements along with the result you want with these data, we will be able to work with them.

Regards
Michel

[Updated on: Tue, 26 January 2010 10:27]

Report message to a moderator

Re: Pivot Table [message #440680 is a reply to message #440674] Tue, 26 January 2010 10:33 Go to previous messageGo to next message
tiagocscoelho
Messages: 3
Registered: October 2009
Location: madrid
Junior Member
Hi !

Thank you for your fast response.

I've seen that topic but i wanted to do it into a view!

For security reasons i don't have enough privileges to create tables!

So i'm looking for a way to do it throw a view.

thanks
Re: Pivot Table [message #440683 is a reply to message #440680] Tue, 26 January 2010 10:48 Go to previous message
Michel Cadot
Messages: 63806
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
For security reasons i don't have enough privileges to create tables!

Do not create table, just post here the statement to do it.

Quote:
So i'm looking for a way to do it throw a view.

You cannot create a view without knowing the number, name and datatype of its columns.

Regards
Michel
Previous Topic: Pivot Style Query
Next Topic: Date value shows 00-000-0000
Goto Forum:
  


Current Time: Tue Sep 27 16:07:28 CDT 2016

Total time taken to generate the page: 0.06887 seconds