Solved

Crosstab Query

Posted on 2003-11-23
2
2,964 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
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 34

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now