Home » SQL & PL/SQL » SQL & PL/SQL » can i display query result in matrix view (merged 4)
can i display query result in matrix view (merged 4) [message #386928] Tue, 17 February 2009 05:21 Go to next message
tarekfathi2003
Messages: 23
Registered: August 2008
Location: kw
Junior Member
hi
i made this query
SELECT row_number() over(PARTITION BY dtl.country_id ORDER BY year) rn,
                   dtl.value THE_VALUE  ,dtl.country_id country, HDR.YEAR
                   FROM crs_v_report_hdr hdr,crs_v_report_dtl dtl
                   where dtl.RHDR_ID = hdr.id
                   and hdr.REP_ID = 1
                   and hdr.YEAR between 2003 and 2006   


this query display the value of each country in each year.
the reasult like this

RN THE_VALUE COUNTRY YEAR
--------- ---------- ---------- ----------
1 .3 2 2003
2 2.6 2 2004
3 5.3 2 2005
4 9.1 2 2006
1 -.1 3 2003
2 0 3 2004
3 .3 3 2005
4 .1 3 2006
1 2.7 5 2003
2 3.8 5 2004
3 3.1 5 2005

Can i display this query display as a matrix view.
In other words, i want to display the year as X axsi and the country as Y axsis and the value as a cell value
it it possible
I tried alot but i faild
Re: is it possible to display rows as columns [message #386930 is a reply to message #386928] Tue, 17 February 2009 05:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes, you can search for "pivot".

Post a Test case: create table and insert statements along with the result you want with these data.

Also always post your Oracle version (4 decimals).

Regards
Michel
Re: is it possible to display query as matrix [message #386935 is a reply to message #386928] Tue, 17 February 2009 05:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Don't multipost your question.

Regards
Michel
Re: can i display query result in matrix view [message #386939 is a reply to message #386928] Tue, 17 February 2009 05:38 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
STOP spamming the forum with the same question but POST WHAT IS ASKED.

Regards
Michel
Previous Topic: UTL_FILE & DBMS_LOB
Next Topic: Escape special character !! (merged)
Goto Forum:
  


Current Time: Sun Dec 04 00:29:41 CST 2016

Total time taken to generate the page: 0.07258 seconds