need to sum all the sal

My dear

This query, I know sal sum in dept by job is

I have to add new coumn in sum to give query for all dept

and new line give sum for each Department

as a matrix report

WITH pivot_data AS (SELECT deptno, job, sal FROM emp)

SELECT "JOB."

"10."

"20."

'30 ',.

"40".

OF pivot_data PIVOT (SUM (sal)

FOR deptno

(10, 20, 30, 40)

)

Hello

So, besides the total sal for each combination of deptno and job, you want also totals for each jdeptno (regardless of the job) and work (regardless of deptno) and a total general (no matter the deptno and employment).  This sounds like a job for the CUBE.  The following soLution uses the CUBE to calculate amounts and then uses the PIVOT just to combine lines.

WITH all_jobs AS

(

SELECT DISTINCT job

FROM scott.emp

)

data_to_pivot AS

(

SELECT deptno NVL (d.deptno, - 1)

, NVL (j.job, 'ALL') AS job

, NVL (SUM (e.sal), 0) AS sal

GROUPING (j.job) AS job_agg

OF scott.dept d

CROSS JOIN all_jobs j

LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno

AND e.job = j.job

GROUP BY CUBE (d.deptno, j.job)

)

Simply SELECT employment, '10', all_depts '20', '30', '40', - or everything *, if you don't mind saw job_agg

OF data_to_pivot

PIVOT (MIN (sal)

TO deptno IN (10, 20, 30, 40

All_depts AS-1

)

)

ORDER BY job_agg

work

;

Output:

ALL_DEPTS 10 20 30 40 JOB

--------- ----- ----- ----- ----- ---------

0 6000 0 0 6000 ANALYST

1300 1900 950 0 4150 CLERK

MANAGER OF 2450 2975 2850 0 8275

THE PRESIDENT 5000 0 0 0 5000

0 0 5600 0 5600 SELLER

ALL THE 8750 10875 9400 0 29025

Instead of deriving a "table" of all possible jobs, you should be able to use a partitioned outer join, something like this:

WITH pivot_data AS

(

SELECT deptno NVL (d.deptno, - 1)

, NVL (e.job, 'ALL') AS job

, NVL (SUM (e.sal), 0) AS sal

GROUPING (employment) AS job_agg

OF scott.dept d

LEFT OUTER JOIN scott.emp e PARTITION BY (e.job)

ON e.deptno = d.deptno

GROUP BY CUBE (e.job, d.deptno)

)

SELECT *.

OF pivot_data

PIVOT (MIN (sal)

TO deptno IN (10, 20, 30, 40

All_depts AS-1

)

)

ORDER BY job_agg, job

;

But the only effect of the outer join partitioned seems to cause CUBE to abandon some Super aggregates.  I do something ridiculous in this second request, or there is a bug in my version (11.2.0.2.0 Express).

(Almost always, when people say "there must be a bug", they're just doing something stupid.)  There is no reason to think that I am an exception.  I don't have another version of Oracle at hand right now)

Tags: Database

Similar Questions

  • What do need me for when the sale of an iPhone that won't turn on in order to remove my information?

    What do need me for when the sale of an iPhone that won't turn on in order to remove my information?

    If it lights why if someone buy it?

  • Hi, I have a problem that only happens in Firefox (under IE does not): when I Middle click the mouse it opens a new tab, but it also grow my Web site to the top of the page & I need to drag all the way back to where I was. Please I need a solution! Th

    When I Middle click with the mouse, it opens a new tab and also pushing my website to the top of the page and it's really annoying when I need to drag all the way back to where I was

    URL of your Web site? And an example of a hyperlink that does this?

  • Satellite Pro L40 PSL43E I need to find all the drivers XP

    I need to find all the XP drivers for this laptop in particular. Any ideas where I can find them. on this site, I get only the ' how downgrade "Pease help ASAP.

    If these drivers are available, you will be able to find these drivers on the European driver Toshiba page.

    If the drivers are not available on the European driver Toshiba page, the pilots were not released.

    But I have a suspicion; I found some XP for Sat L40 series drivers. Some series supports the same devices and so the drivers should work also.
    Check some unique XP from different L40 series drivers and maybe he would go.

    Ciao

  • How can I erase whatever it is associated with to Brother DCP-1200. It was added by mistake. I need to erase all the files on my computer related to Brother DCP-1200

    How can I erase whatever it is associated with to Brother DCP-1200.  It was added by mistake. I need to erase all the files on my computer related to Brother DCP-1200?

    You uninstall it?

    I could only partially uninstall the printer. It is not to add printers & devices more. It is not in the list of program. But he is still using a driver. Therefore, I can't fix it just delete it from the Driver list. I don't know anything else to do. Can you give me any suggestions? It makes my computer thinks that it must be installed. JoAnn

  • Need to see all the settings in the bios!

    I have a laptop HP G60 - 247CL

    I just put in 4 gigabytes of ram from corsair gaming super fast! Make sure that the settings are correct on the clock on the cylinder speed. Need to see all the settings in the bios but shows no not the memory clock speed!

    How to unlock bios to display all the freaking parameters. If I knew that HP has locked the bios, I would not have bought this piece of shit!

    I can't get CPU - Z no much, but that does not give me the ability to change speeds of memory. I need to make sure that they correct r. I need to be able to enter the wood to make changes. Locking the BIOS settings is really stupid!

    Message edited by hozer on 10/27/2009 16:26
    Message edited by hozer on 28/10/2009 09:06
    Message edited by hozer on 28/10/2009 09:07

    While the Insyde BIOS that is supplied with the units of G60 is insufficient information, there are other routes, you can take to check your ram timings. I found that the timing of the memory itself with enough accuracy on my G60-235 and was able to check it with CPU - Z and Everest Ultimate. (Which are both a freeware or a functional demo.)

    In particular, I noticed that the adjusted to 5-5-5-15 timings (OCZ DDR2-6400) after replacing the modules Kingston stocks. (Which seems to me to remember turned to 6-6-6-18).

    I hope this helps.

  • My computer has been fitness. I need to reinstall all the programs. How to do? I pay every month 35 shekel

    my computer has been reformtting. I need to reinstall the cloud creative adobe. How to do? I pay every month 23 shekel

    thank - li

    Please see a reformat my computer. I need to reinstall all the programs. How to do? I pay each month a shekel 35

    (Double post)

  • I need to select all the blocks of text in a document and align text blocks in the back pages left frame margin and the text in the pages front to the right margin.

    Hello

    Am new to Java script.

    Can someone help me out here, I need to select all the blocks of text in a document and align text blocks in the pages back to the left margin frames and text in pages recto at the right margin.

    Thank you
    Harish

    Hi Harish,

    Try this.

    var doc =app.activeDocument,
        _pages = doc.pages;
    doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    for(var i =0;i<_pages.length;i++)
    {
            txfms = _pages[i].textFrames.everyItem().getElements();
            for(var j =0;j
    

    Kind regards

    Cognet

  • Need to get all the text of the particular applied character style

    Can someone help me I need to get all the texts of the particular applied character style

    app.findTextPreferences.appliedCharacterStyle = 'style1 Character. "

    app.findTextPreferences.appliedCharacterStyle = 'style1 Character. "

    var mf = app.activeDocument.findText ();

    var myText = ";

    for (var i = 0; i)<>

    myText is myText + mf [i] .silence;.

    }

    Alert (MyText);

  • HP 14-R217TU: need software driver all the

    I need windows 10 32-bit all associated driver software. Please help me...

    Please click the link below to have access to all the drivers and even download to your laptop

    http://support.HP.com/us-en/drivers/selfservice/HP-14-R200-notebook-PC-series/7486429/model/7597727#Z7_3054ICK0K8UDA0AQC11TA930O2

    Hope this helps, for other queries in response to the post and feel free to join us again

    * Click on the white button on the right to say thank you Thumbs Up *.

    Make it easier for others to find solutions by checking a response "Accept as Solution" if it solves your problem.

    Thank you

    K N R K

    Although I am an employee of HP, I speak for myself and not for HP

  • Need to delete all the memory

    I'm selling my laptop, but before I can I need to delete all of my friends out of it. I realized how do it, but now my computer won't turn on. I bought a new battery and a new charger, but the charger does not work, and now I've lost the old one.

    Does anyone have advice? I tried out the battery and now the power for 30 seconds button. Nothing happened.

    Hi jkeppl1,

    You have not provided the model of your laptop, but I guess it is old enough. The general approach in this situation would be to remove the hard drive, put it in an external hard drive enclosure, plug this case into the USB port on another PC and run your utility. Since the laptop does, however, my suggestion would be to simply sell without a hard drive, since even a plu working laptop won't be worth much more that $50 any way, much less one that won't turn on.

    I recently got an Inspiron N5010 without hard drive that wasn't turn on for free. I have solved the problem, install a hard drive $ 15, installed Windows 7 and gave it to a family member. The thing works beautifully.

  • Need to find all the possible child records with SQL

    Hello - I am trying to find a way to solve the following with a sql statement:

    I have a table with columns, and the following values:
    Trans_Id   Parent_Trans_id
    1             null
    2             1
    3             2
    4             3
    So basically, 1 is the master parent and I need to bring all ranks, because they are all ultimately originated due to 1. How to write sql code to return all possible levels associated with parent_id = 1?

    I hope I'm communicate that effectively do this, but please let me know if it needs to be clarified.

    Any help is greatly appreciated...

    Thank you
    Christine

    Hi, Christine.

    I think you want to CONNECT BY, something like this:

    SELECT     *
    FROM     a
    START WITH     trans_id      = 1
    CONNECT BY     parent_trans_id      = PRIOR trans_id
    ;
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}
    You will find the answers better faster if you always provide this information whenever you post a question.

  • HP envy 15z j000: need to know all the drivers to install to my computer...

    Right then, I've upgraded to windows 10 and was to be funky, so I decided to do a factory reset. To restart the computer it gave me the bsod saying inaccessible boot drive, so I created a usb startup disk and installed windows 8 but now all the drivers that came on my computer are gone including the reader of fingerprints, coolsence and the beats audio. If anyone can help me with links for each one or a list or something that would be surprising. Thank you.

    You can use HP Support Assistant to help you decide, or you can open this http://support.hp.com/us-en/product/HP-ENVY-15-j000-Notebook-PC-series/5354982/model/5388061/drivers and press 'Check now' to automatically detect software to download

  • I need to delete all the files and restart lightroom?

    I just downloaded Lightroom and by mistake I loaded all THE image files. Instead of 6 000 JPEG files, I have 23 000 images. I would like to start over. What are my choices?

    Thank you (and yes I feel a fool, isn't the first and won't be the last).

    Graham.

    Hi Graham,

    If you chose to add import, choose all of the photographs in the catalog Panel in the library module > select all photos, and then press the delete key > choose Remove (do not choose Remove them the disc as that would remove the original images)

    Or, you can start fresh with a new, empty catalog by clicking file > new catalog.

    Kind regards

    Claes

  • Re: Files I've accidentally pressed + create new folder. It changed all my file names to now show the full path that is users/Michael/pictures... and I see is no longer the name of the folder.  I use folders for EVERYTHING and I need to go all the way

    CC Lightroom library module: I tried to do something else and I pressed on '+ create a new folder.  All the names of my files now have the full path as their name, i.e. of C:\Users/Michael...  It changed my folder name so much more that I can see is no longer.  I use folders for EVERYTHING.  I never use collections or anything else, and my inability to quickly determine the names of my files is driving me crazy.  How can I get rid of all this nonsense of path?  He was never there until I hit this sign.

    On the same dropdown menu selected "name of folder only.

Maybe you are looking for

  • Serial number v220w to USB Flash disk problem

    Hello world. I bought a v220w hp usb flash drive and not found any number that looks like serial number. I need serial number for troubleshooting. Can someone tell me about the location of serial number in v220w hp flash drive?

  • How to set the frame rate of NOR-IMAQdx

    Hello. The actual frame rate is 30 fps (MAXIMUM), but I must decrease the value to 10 frames per second. Is this possible?.

  • Alienware R5 Ram

    I just got an Alienware R5 with 8 GB of ram and I am looking to buy 4 GB of ram, I really don't like this is how fancy, it's just to give it a little more juice. I was wondering what size use, ram comes in many different sizes for the pins and I was

  • DVD player does not recognize disk ERROR "Please insert a disc into drive F".

    Any disk I put in DVD Player my cell phone, he won't play. If I go to the file in Windows Explorer and click on DVD RW drive (f :)), it ejects all that is currently in the player, saying: "Please insert a disc into drive F:." My computer is a Lenovo

  • Condenser USB microphone does not

    Hello community, I have a huge problem. I got a usb to CCU1 condenser microphone and a new machine, I tried to plug it in it try to install, but this error: [img] http://www.imagelink.cz/images/semttulo.jpg [line][img] http://www.imagelink.cz/images/