Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> Rows as Columns and Vis a vis

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Rows as Columns and Vis a vis
 Rajnish  Posted: Apr 21, 2006 04:35:46 AM

 Total Post: 2
 Joined: Apr, 2006






 Hi,

I have data in a table as follows:

CLIENT REVNO QTY1 RATE1 QTY2 RATE2 QTY3 RATE3

cln1 1 50 120 60 130 70 140
cln1 3 10 100 20 50 30 25
cln1 4 40 50 30 25 40 15
cln1 2 20 120 10 60 20 30
cln1 5 25 70 15 35 30 18


I require output in following format:

For each client,

In each record, qty1 and rate1 for revno=5 should come first then qty2 & rate2 of revno=4 and so on..

cln1 25 70 40 50 10 100 20 120 50 120

cln1 15 35 30 25 20 50 10 60 60 130

cln1 30 18 40 15 30 25 20 30 70 140


for next client,

3 more rows will come.


In the first record of above result "25" is qty1 of revno=5 & "70" is rate1 of revno=5
similarly, "40" is qty1 of revno=4 and "50" is rate of revno=4 and so on ..

In the second record, "15" is qty2 of revno=5 and "35" rate2 of revno=5 and so on.

So basically,
it should be qty1 & rate1 of revno 1through 5 in 1st records then
qty2 & rate2 of revno 1 through 5 in 2nd record
and qty3 &rate3 of revno 1to5 in 3rd record.

Any suggestions.

 Subhranil
Posted: May 27, 2006 11:22:16 PM  

 Total Post: 28
 Joined: Jul, 2005






 
We better to create a temporary table fill it up according to your query and then query the temp table.

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi334
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software