Solved

Query formation

Posted on 2012-04-09
8
242 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
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.

 
LVL 32

Accepted Solution

by:
awking00 earned 500 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

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.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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…

777 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