Solved

Crosstab Query

Posted on 2003-11-23
2
2,997 Views
Last Modified: 2011-09-20
In MS Access, there is a command TRANSFORM... PIVOT... to produce a crosstab query.

Is there any command or functions that is similar to the TRANSFORM... PIVOT... command of MS Access??

0
Comment
Question by:shlikjohn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Expert Comment

by:andrewst
ID: 9809523
Reporting tools have such features - e.g. Oracle Reports can create "matrix reports".   SQL Plus and the SQL language do not.  A standard way to create a crosstab query in Oracle SQL is:

select s.region,
         sum( decode( s.year, 2001, s.value, 0 )) sales_2001,
         sum( decode( s.year, 2002, s.value, 0 )) sales_2002,
         sum( decode( s.year, 2003, s.value, 0 )) sales_2003,
         ...
from sales s
where ...
group by s.region;
 
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 100 total points
ID: 9810484
The simple answer is: No.  The comment from andrewst describes the two most common ways to accomplish this in Oracle, but they each have disadvantages.  The first approach requires buying (and learning to use) Oracle Reports, and this is not the most user-friendly reporting tool on the market.  The second approach (with "decode") requires you to know and write code for all of the different possible values in the data.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create table from select - oracle 6 68
Oracle - SQL Query with Function 3 68
sum of columns in a row in oracle 3 44
Need help on decision table structure 7 46
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question