Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Query formation

Posted on 2012-04-09
8
Medium Priority
?
248 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
Independent Software Vendors: 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!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
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…
Suggested Courses

876 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