Improve company productivity with a Business Account.Sign Up

x
?
Solved

Query formation

Posted on 2012-04-09
8
Medium Priority
?
251 Views
Last Modified: 2012-06-22
Hi,

1. main query.sql file attached

2. mainquery result set is attached

3. Required format of the result set attached in the excel "TO BE RESULT SET.XLS.xlsx"

Please help to achive this format.

Thanks
Main-query.sql
mainquery-result-set.xlsx
TO-BE-RESULT-SET.XLS.xlsx
0
Comment
Question by:neoarwin
  • 5
  • 3
8 Comments
 
LVL 32

Expert Comment

by:awking00
ID: 37823578
Because they appear to be left_justified, may we assume that date_only, sector, month, and month_nr as of character datatype?
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823593
cmpgn_yr as well?
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823735
What version of Oracle are you using?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
LVL 32

Accepted Solution

by:
awking00 earned 2000 total points
ID: 37823784
Try this
select rtrim(xmlagg(xmlelement(e,date_only||',')).extract('//text()'),',') date_only
      ,rtrim(xmlagg(xmlelement(e,res_cell||',')).extract('//text()'),',') res_cell
      ,sector
      ,region
      ,month
      ,month_nr
      ,cmpgn_yr
      ,division
from (<your main query>)
group by sector, region, month, month_nr, cmpgn_yr, division;
0
 

Author Comment

by:neoarwin
ID: 37824148
Hi,

Sorry for the delayed reply.

My oracle version is 10g.

Regards
0
 
LVL 32

Expert Comment

by:awking00
ID: 37824508
Then my last response should work.
0
 

Author Comment

by:neoarwin
ID: 37826668
Please check the attachd images.
The order of date_only is not matching with order of res_cell..

Please help resolve, this is the same problem I am facing when using wm_concat as well.
results-obtained.JPG
Required-result-order.JPG
0
 

Author Closing Comment

by:neoarwin
ID: 37826846
Thank you
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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 …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

607 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