[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/13/2000 at 06:44AM PST, ID: 11845279
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

How do you create a select statement that dynamically converts rows into columns ?

Asked by falconsoft in Oracle Database

Tags: oracle, table_rows

Basically I want to get this data displayed in the format returned by the two last statements
where the number of columns is defined dynamically and not explicitly in the statement.

Something where the column name is the grouped value of the rows.  (crosstab views)

/* Sample statements */

DROP TABLE var_data ;

CREATE TABLE var_data
 (key_id      NUMBER,
  column_name VARCHAR2(30),
  data_value  VARCHAR2(30)) ;

desc var_data

insert into var_data values (1, 'C1', 'V1') ;
insert into var_data values (1, 'C2', 'V2') ;

insert into var_data values (2, 'C1', 'V3') ;
insert into var_data values (2, 'C2', 'V4') ;

insert into var_data values (3, 'C1', 'V5') ;
insert into var_data values (3, 'C2', 'V6') ;
insert into var_data values (3, 'C3', 'V7') ;

commit ;

set heading on
select * from var_data ;

key_id  column_name      data_value
------  -----------     ----------
1      C1            V1
1      C2            V2
2      C1            V3
2      C2            V4
3      C1            V5
3      C2            V6
3      C3            V7

-- Oracle 7.3 and above
select key_id, max(C1) C1, max(C2) C2
  from (select key_id, decode(column_name, 'C1', data_value, NULL) C1, decode(column_name, 'C2', data_value, NULL) C2
        from var_data)
group by key_id ;

key_id  C1      C2
------  --      --
1      V1      V2
2      V3      V4
3      V5      V6

-- Oracle 8.1.6 and above
SELECT key_id,
       MAX((CASE WHEN column_name = 'C1' THEN data_value END)) C1,
       MAX((CASE WHEN column_name = 'C2' THEN data_value END)) C2
  from var_data
GROUP by key_id ;

key_id  C1      C2
------  --      --
1      V1      V2
2      V3      V4
3      V5      V6



/* END Sample statements */

[+][-]11/13/00 07:51 AM, ID: 5296799

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/00 08:11 AM, ID: 5297420

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/00 10:30 PM, ID: 5317899

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/14/00 06:49 AM, ID: 5327799

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/14/00 11:46 PM, ID: 5352681

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/15/00 06:26 AM, ID: 5358421

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/15/00 06:28 AM, ID: 5358446

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/16/00 04:41 AM, ID: 5385222

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/16/00 06:03 AM, ID: 5386763

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: oracle, table_rows
Sign Up Now!
Solution Provided By: randyd
Participating Experts: 5
Solution Grade: B
 
 
[+][-]04/29/02 02:33 PM, ID: 6978713

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/02 11:17 AM, ID: 7054505

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91