Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion SQL Query: Switching Rows to Columns dynamically.
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michel Cadot  
View profile  
 More options Oct 17 2006, 12:04 pm
Newsgroups: comp.databases.oracle.misc
From: "Michel Cadot" <micadot{at}altern{dot}org>
Date: Tue, 17 Oct 2006 18:04:25 +0200
Local: Tues, Oct 17 2006 12:04 pm
Subject: Re: SQL Query: Switching Rows to Columns dynamically.

"Anil G" <anil.got...@gmail.com> a écrit dans le message de news: 1161038711.676290.252...@i3g2000cwc.googlegroups.com...
| Guys:
|
| I am looking to develop SQL query which will switch the rows to
| Columns. I was trying with DECODE statements but that leads to
| hardcoding of types. Any one has any clues to develop dynamic logic to
| convert rows to columns. Following is detailed information about
| problem.
|
| Thanks in advance,
| Anil G
|
| ----------------------------------------- problem statement
| ---------------------------------------------------------------
| type_tbl
| + name
|
| data_tbl
| + org
| + type_name
| + data_value (FK to type_tbl)
|
| -----
| Data layouts: type_tbl, user can keep adding types from the
| application.
|
| type_tbl
| --------
| T-1
| T-2
| T-3
| T-4
| ..
| ..
|
| data_tbl
| -------
| org type_name data_value
| ---- --------- -----------
| O-1 T-1 100
| O-1 T-2 30
| O-1 T-3 45
| O-2 T-1 100
| O-2 T-4 30
| O-3 T-1 45
|
|
| Desired Output:
| ---------------------------------------------------
|
| org T-1 T-2 T-3 T-4 .....
| --- --- --- --- --- --
| O-1 100 30 45
| O-2 100 0 0 25
| O-3 45
|
| --------------------------------------------------------- Ends
| -------------------------------------------------------------
|

I posted a solution for such a problem on Ask Tom (it was about students and classes but the principle is the same):
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:52...

Regards
Michel Cadot


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.