Put the 'dynamic' on top headers a pivot

I have a table that I organize by exercise, with months, from April to March each year.

I have everything worked except for how to get the names of exercise as column headings. Even though I have to_char had values, I always get an ORA-1790 expressioon must have the same data type when I try to UNION ALL headings on the rest of the data.

The two components work fine separately. Miss me probably just something simple, but what? (the original problem has a table with data of 18 years - I gave three only for brevity)

Thank you

Jon

Desired is output:

M 2011/2012 2012 2013 2013/2014 1 25194 24716 24015 2 25275 24794 23916 3 25005 24475 23592 4 24770 24577 23471 5 24806 24470 23543 6 24795 24265 23606 7 24636 24318 23504 8 24664 24262 23307 9 24406 24119 23293 10 24717 24039 23355 11 24718 23910 23317 12 24637 23894

The table is:

create table rb_raw (date of the m_date, total_cases number (6));

insert into rb_raw values (to_date('01-JAN-11','dd-mon-yy'), 25119);

insert into rb_raw values (to_date('01-FEB-11','dd-mon-yy'), 25026);

insert into rb_raw values (to_date('01-MAR-11','dd-mon-yy'), 25305);

insert into rb_raw values (to_date('01-APR-11','dd-mon-yy'), 25194);

insert into rb_raw values (to_date('01-JUN-11','dd-mon-yy'), 25005);

insert into rb_raw values (to_date('01-JUL-11','dd-mon-yy'), 24770);

insert into rb_raw values (to_date('01-AUG-11','dd-mon-yy'), 24806);

insert into rb_raw values (to_date('01-SEP-11','dd-mon-yy'), 24795);

insert into rb_raw values (to_date('01-OCT-11','dd-mon-yy'), 24636);

insert into rb_raw values (to_date('01-NOV-11','dd-mon-yy'), 24664);

insert into rb_raw values (to_date('01-DEC-11','dd-mon-yy'), 24406);

insert into rb_raw values (to_date('01-FEB-12','dd-mon-yy'), 24718);

insert into rb_raw values (to_date('01-MAR-12','dd-mon-yy'), 24637);

insert into rb_raw values (to_date('01-APR-12','dd-mon-yy'), 24716);

insert into rb_raw values (to_date('01-JUN-12','dd-mon-yy'), 24475);

insert into rb_raw values (to_date('01-JUL-12','dd-mon-yy'), 24577);

insert into rb_raw values (to_date('01-AUG-12','dd-mon-yy'), 24470);

insert into rb_raw values (to_date('01-SEP-12','dd-mon-yy'), 24265);

insert into rb_raw values (to_date('01-OCT-12','dd-mon-yy'), 24318);

insert into rb_raw values (to_date('01-DEC-12','dd-mon-yy'), 24119);

insert into rb_raw values (to_date('01-JAN-13','dd-mon-yy'), 24039);

insert into rb_raw values (to_date('01-FEB-13','dd-mon-yy'), 23910);

insert into rb_raw values (to_date('01-MAR-13','dd-mon-yy'), 23894);

insert into rb_raw values (to_date('01-APR-13','dd-mon-yy'), 24015);

insert into rb_raw values (to_date('01-JUN-13','dd-mon-yy'), 23592);

insert into rb_raw values (to_date('01-JUL-13','dd-mon-yy'), 23471);

insert into rb_raw values (to_date('01-AUG-13','dd-mon-yy'), 23543);

insert into rb_raw values (to_date('01-SEP-13','dd-mon-yy'), 23606);

insert into rb_raw values (to_date('01-OCT-13','dd-mon-yy'), 23504);

insert into rb_raw values (to_date('01-NOV-13','dd-mon-yy'), 23307);

insert into rb_raw values (to_date('01-DEC-13','dd-mon-yy'), 23293);

insert into rb_raw values (to_date('01-MAY-11','dd-mon-yy'), 25275);

insert into rb_raw values (to_date('01-MAY-12','dd-mon-yy'), 24794);

insert into rb_raw values (to_date('01-MAY-13','dd-mon-yy'), 23916);

insert into rb_raw values (to_date('01-JAN-14','dd-mon-yy'), 23355);

insert into rb_raw values (to_date('01-FEB-14','dd-mon-yy'), 23317);

insert into rb_raw values (to_date('01-JAN-12','dd-mon-yy'), 24717);

insert into rb_raw values (to_date('01-NOV-12','dd-mon-yy'), 24262);

and my current query (with the part of the position currently set comment):

with b as

(Select to_char (basefisc - (18-y)) |) '/' || TO_CHAR (basefisc - (17-y)) fyear, m_date, y, m, to_char (total_cases) total_cases

Of

(select m_date, / * months_between (m_date, f.fystart) MB, * / floor ((months_between (m_date,f.fystart)-1) / 12) + 18 y,)

CASES WHERE extract (m_date months) > 3 then extract(month from m_date)-3 9 other + extract (m_date months) end m.

extract (year fystart) basefisc, total_cases

of rb_raw

cross join

(select case when extracted (month of to_date (: current_month, 'YYYYMM')) < 3 then add_months (to_date (": current_month, ' YYYYMM"), - 9-extract (month of to_date (: current_month, 'YYYYMM'))))

else add_months (to_date (": current_month, ' YYYYMM"),-(extrait (mois de to_date (: current_month, 'AAAAMM'))-4))

end fystart

the double) f

where the floor (months_between (m_date, f.fystart) / 12) + 18 > 0

order of m_date)

)

--

Select *.

Of

(/ *(select *))

Of

(select 0 m, fyear)

b

)

Pivot (max (fyear) for y in (16,17,18)))

UNION ALL * /.

(select *)

Of

(select y, m, total_cases

b

)

Pivot (sum (total_cases) for y in (16,17,18)))

)

order by m

;

Hi, Jon,

This can give you some ideas on how to increase the effectiveness of your request (and, at least in my opion) more easy to understand:

WITH years_wanted AS

(

SELECT LEVEL AS no_y

EXTRACT (YEAR FROM ADD_MONTHS (TO_DATE (: current_month, "YYYYMM")))

9 + (12 * (1 - LEVEL))

)

) As the exercise

OF the double

CONNECT BY LEVEL<= 3 ="" --="" change="" to="" 18="" for="" final="">

)

got_fy AS

(

SELECT TO_CHAR (EXTRACT (MONTH OF ADD_MONTHS (m_date-3))

'99'

)                                AS month

, TO_CHAR (total_cases, "999999") AS total_string

EXTRACT (YEAR FROM TRUNC (ADD_MONTHS (m_date, 9)))

, 'YEAR '.

)

)                                AS fy

Rb_raw r

)

SELECT 'MONTH' by MONTH

-, MAX (CASE WHEN no_y = 18 THEN (fy - 1) |) '/' || the fiscal year END) AS y18

--        ...

, MAX (CASE WHEN no_y = 3 THEN (fy - 1) |) '/' || the fiscal year END) AS y3

, MAX (CASE WHEN no_y = 2 THEN (fy - 1) |) '/' || the fiscal year END) AS y2

, MAX (CASE WHEN no_y = 1 THEN (fy - 1) |) '/' || the fiscal year END) AS y1

Of years_wanted

UNION ALL

SELECT month

-, MAX (CASE WHEN w.y_num = 18 THEN f.total_string END) AS y18

--        ...

MAX (CASE WHEN w.y_num = 3 THEN f.total_string END) AS y3

MAX (CASE WHEN w.y_num = 2 THEN f.total_string END) AS y2,

MAX (CASE WHEN w.y_num = 1 THEN f.total_string END) AS y1,

OF got_fy f

JOIN years_wanted w f.fy = w.fy

GROUP BY f.month

ORDER BY month

;

This option displays the exercises 3 (or 18), ending with one that includes: current_month.

Given your sample data and: current_month = '201403', the output is:

MONTH 2011/2012 2012 2013 2013/2014

1 25194 24716 24015

2 25275 24794 23916

3 25005 24475 23592

4 24770 24577 23471

5 24806 24470 23543

6 24795 24265 23606

7 24636 24318 23504

8 24664 24262 23307

9 24406 24119 23293

10 24717 24039 23355

11 24718 23910 23317

12 24637 23894

Tags: Database

Similar Questions

  • Put the media on top a Photoshop image

    I currently have a Web site that is the basis of Photoshop. I created a whole page on Photoshop, including all my texts and images. I used hot spots / image maps to connect users to different pages. But I'm unable to make components related flash in Photoshop. (Example: the Dream Weaver image viewer). My question is, how am I able to place an image view my Web page in Dreamweaver on top of the Photoshop image? I tried to make the layers, but the problem is that it has a fixed position and he won't be able to adapt to different sizes of office. I want to view image must be able to move toward the Center with my Web site.

    I currently have a Web site that is the basis of Photoshop.

    If you browse this forum, I bet you will see that > 50% of the posts here are people who took just that approach.  Photoshop (and Fireworks) do not write quality production HTML.  The HTML code you get from any graphic application is extremely "brittle" and will break as soon as you start to change the shape of the content of each page.  You must use a graphics application to make your graphics card and a HTML element writing system to write your HTML code.  It's the truth.

    I created a whole page on Photoshop, including all my texts and images. I used hot spots / image maps to connect users to different pages.

    The content of your text is part of the image?  You realize that you won't get ranked by search engines when you do that, right?  It's the worst thing you can do, really.

    My question is, how am I able to place an image view my Web page in Dreamweaver on top of the Photoshop image?

    Now you have found in the heart of the case.  To tell you how to do this, we must use the language HTML and CSS-talk, that you're not likely to understand if you use Photoshop just to write your HTML code.  The answer to your question is that you make your graphics a background image of the container involved and place your support in this container, properly oriented in this direction using padding and margins.

    I tried to make the layers, but the problem is that it has a fixed position and he won't be able to adapt to different sizes of office. I want to view image must be able to move toward the Center with my Web site.

    You can do this way, * and * make the center of the element to absolute positioning with Web site by wrapping the entire page in a container positioned relatively, for example, and balance

    ... the rest of the code from your page...

  • Question about the code on top a sliced image

    Hello. I'm building a website for a school project, and I was hoping that someone could tell me how to put the code on top a slice of Photoshop image in Dreamweaver? I'm putting a Flash video on my site into slices.

    I'm putting a Flash video on my site into slices.

    Fagetabout it!  Flash cannot be considered by the majority of users.  He's dead.

    Facebook calls for the end of Flash as a Firefox it blocks on hacking holes | The technology | The guardian

    See my answer to the question williaml42842247 below:

    My FLV files is not playing after loading of the landing page. Video works offline but not online? Thank you!

    Nancy O.

  • Exclude a measure the total general dynamic level 'Lines' of a pivot table

    Experts,

    Is it possible to exclude a measure the total general dynamic level 'Lines' for a pivot table?

    Version - OBIEE 10g

    Kind regards
    LIBERATOR

    No, I mean not the dropdown list above when you edit the formula in the column. It of there on 11g but don't remember off the top of my head if it is in the same place on 10g.

    Paul

  • Is it safe to use keyboard if I put the microfibre cloth on top of the keypad cover when I close the mac? (mac pro retina display)

    Hi all.

    I use Kuzy keyboard cover on my mac pro retina display.

    I read that Apple does not recommend to use the keypad cover when you close the mac of retina display.

    So I wonder if it would be dangerous to use key cover if I put the microfibre cloth on top of the keypad cover when I close the mac?

    In this way, would the retina display not scratched by a keyboard cover?

    Please share an idea about it, thank you.

    It is not only the possibility of a scratch, but also that the MacBook Pro retina are very thin. Adding a keyboard cover and a cloth could lead to damage and it closes does not correctly. I have personally not use either on my rMBP.

    To activate the thin design of MacBook Pro with computers of Retina display, the distance between the screen and the top box is designed to close tolerances. Do not use palm rest covers or covers of CAP, because the extra thickness can interfere with the closing designed screen position.

  • When I open a program that takes a few seconds to load and open another program while I'm waiting, it will automatically put the first window on top

    When I open a program that takes a few seconds to load and open another program while I'm waiting, it will automatically put the first window on top when it has finished loading.  How do I not do?

    Hello

    Unfortunately, it is not possible to change that outside of the modification of the order in which the programs open.

    If you have feedback or suggestions, you can express their opinion on this at:

    http://connect.Microsoft.com

    It will be useful.

  • I had to put new hard shore Studio dell with vista. How can I put the toolbar back across the top of the desktop? I thought it was called a Ribbon?

    I had to put new hard shore Studio dell with vista. How can I put the toolbar back across the top of the desktop? I thought it was called a Ribbon?

    A question = a post in these Forums.

    http://social.answers.Microsoft.com/forums/en-us/vistaappearance/thread/465e87c6-5289-4027-B414-7251bdfecc0e

    Answered in another Thread.

    Mick Murphy - Microsoft partner

  • You put the toolbar of office back at the top of the screen?

    How can I put the toolbar 'Office' back at the top of the desktop computer, you know the tool bar with music, internet and so on? Help, please

    On Friday, April 23, 2010 22:05:43 + 0000, keith50 wrote:
     
    > How can I put the toolbar 'Office' back at the top of the desktop computer, you know the tool bar with music, internet and so on? Help, please
     
     
    If I understand what you are asking the subject, is not a
    Feature of Windows 7, but the Dell Dock, something provided by Dell.
     
    Dell how to put in place.
    Ken Blake, Microsoft MVP (Windows desktop experience) since 2003
     

    Ken Blake

  • I have CS2, CS 4 on two PCs.  I need to buy a laptop for work and I want to put my copy on it.  Can I uninstall of either.  I'll be able to install on the new lap top?

    I have CS2, CS 4 on two PCs. I need to buy a laptop for work and I want to put my copy on it.  Can I uninstall of either.  I'll be able to install on the new lap top?

    Maybe, maybe not... According to the new operating system

    CS2, Acrobat 7 + Audition 3 (AND PREVIOUS) activation server has disappeared, then read below

    l http://helpx.adobe.com/x-productkb/Policy-Pricing/Creative-Suite-2-activation-end-Life.htm

    .

    You MUST use the special version and the serial number on the page, not your original drive or serial number

    .

    When you install the special version of CS2 on a Win7 or Win8 or Win10 computer, you may need to right click on the program icon and select compatibility Windows XP in the popup of option

  • Help!  I'm stuck.  No, not the child into the well.  I took a picture and put a second layer top with a rounded rectangle to make a frame.  My problem is that I need to find a way to hide the small box outside the box on the second layer.  Thanks to

    Help!  I'm stuck.  No, not the child into the well.  I took a picture and put a second layer top with a rounded rectangle to make a frame.  My problem is that I need to find a way to hide the small box outside the box on the second layer.  Thanks to all those who can help you.

    Another option is to put the Options bar of the Rectangle rounded to the path tool

    Trash bolt for the background layer, hold down the Cmd key and click on the symbol of the new layer to layer below the image to white. Then edit > fill with white.

    Return the image layer and draw the image as a path

    Click the load as a selection path in the Panel traced

    Edit > stroke and stroke with color

    Select > Inverse > delete

  • I have a modal using html and css that opens very well.  However, given that modal is on layer 2 layer 1 objects fade out (gray out) in the background.  I can't put the modal on the top layer, so that it appears on all my pages.  It is specifi c that

    I have a modal using html and css that opens very well.  However, the modal is on layer 2 that the objects in the layer 1 fade out (gray out) in the background when the modal opens.

    I can't put the modal on the top layer, so that it appears on all my pages.  It is specific to the single page on my site.

    Here is the link: http://www.ueonline.com/website_NEW/certificationsapprovals.html#openModal

    Any help is appreciate!

    You can create a separate mask for this specific page with modal to the top layer and then apply that master page.

    Thank you

    Sanjit

  • How can I put the top of the index page when I moved in my area?

    could be confusing question, sorry.

    Just a click on this page and read the topic please.

    http://bigshouting.cafe24.com/

    When you click, you could see not the top of the page to index but low...

    How can I fix?

    Can you guys explain with procedure?

    The problem is that you have a form at the bottom of the page that has a field set to 'auto '. This means that when the page loads it will automatically put the cursor in the box and of course to do that, she'll have to scroll down to it.

    You must remove the automatic point of this form field or move the shape to the top of the page.

  • put the Insert panel along the top

    PCOC 2014 how can I go to put the Insert panel along the top of the window?

    THX in advance

    Take the "Insert" tab and drag just below the menu bar above. Letting go when a blue line appears.

  • How can I put the hyphenation option in the Control Panel on top of indesign CS6?

    How can I put the hyphenation option in the Control Panel on top of indesign CS6?

    I know how to get to the hyphenation option, but I want the button is more accessible by placing the box setting on the Panel of control/toolbar at the top of my indesign CS6.

    Thank you!

    I think that I've done enough space for it now, then, what is the problem?

    I uncheck paragraph stuff, then why isn't it appear there?

  • any button in the dynamic region you put me the default taskflow

    Hi all

    I used Oracle Adf 12 c,

    I do application with a jsf page and using Panel springboard and inside he ShowDetailItem inside static area Dynmiac area inside.

    Jsf Page > > Panel Spring Board > > view item details > > static region > > dynamic region

    the problem is when I click on the button in the dynamic region it navigate to the default taskflow.

    My problem is solved by changing the scope of the managed bean (application scope in sight).

Maybe you are looking for