BET MAX and second MAX AMOUNT

Hello world

in the EMP table.

I want to get the MAX and second MAX Salary for the 30 and total Department at line 10 in a Department.

Like this

Salary eleve---deuxieme better pay - total dept 10
2850 1600-8750


Kind regards

Mahir M. Quluzade wrote:

select
deptno, maxs "Higher Salary", max(sal) "Second higher Salary",sums "total dept"
from
(

select
deptno,sal,
max(sal) over(partition by deptno) maxs,
sum(sal) over (partition by deptno) sums

from scott.emp
WHERE deptno =10)
where sal != maxs
group by deptno, maxs, sums

UH... they wanted the highest and 2nd highest of deptno = 30, so it should not be something like this...

WITH t_sal AS
(
 SELECT deptno,
        sal,
        ROW_NUMBER() OVER(PARTITION BY deptno ORDER BY sal DESC) rn,
        SUM(sal)     OVER(PARTITION BY deptno ORDER BY deptno) tot
 FROM   emp
),   t_data AS
(
 SELECT deptno,
        sal,
        rn,
        tot
 FROM   t_sal
 WHERE  (rn IN (1,2)
 AND    deptno = 30)
 OR     (rn = 1
 AND    deptno = 10)
)
SELECT MAX(CASE WHEN deptno = 30 AND rn = 1 THEN sal ELSE NULL END) higher,
       MAX(CASE WHEN deptno = 30 AND rn = 2 THEN sal ELSE NULL END) second_higher,
       MAX(CASE WHEN deptno = 10 AND rn = 1 THEN tot ELSE NULL END) total_for_10
FROM   t_data;

?

Published by: Munky on February 23, 2011 13:40 - typo

Tags: Database

Similar Questions

  • Ink advantage 1518: first and second impression is poor third better every time

    For a month, whenever I print a simple text, the first and second copies are of poor quality.  Black ink is faded up or down the page.  Sometimes the second copy is better, but the third copy is fine.  This happens again and again. I took the cartridge HP HP678 and shaken it, but the problem persists.  I lose a lot of paper.

    Any advice?

    Thanks, Stephen

    I'm not familiar with your printer model, but looking at the photos of the cartridges on eBay that looks like they are of the type that is a cartridge with a built-in print head.

    So the next time you need to print instead of print spend by the movements as you would replace a cartridge which, on most printers, I work with you would just open the top cover.

    Remove the black print cartridge and inspect the nozzles, they seem like they have a layer of ink dried on them, then pat dry the nozzles on a wet paper towel folded several thick layers. Blotteded several times after I insert the cartridge and try to print if you get good quality, this means that the head is dry or the wiper cleaning in the gas station is dirty and is wiping the ink dried on the head, clogging of the nozzles.

    Printheads in good condition will give you two solid black when erased ink lines. Or should I say on all the models that I worked and that's what the black print head made the color print head is a little different.

    If my post is a solution to your problem please click the accepted solution button under the post. You can also say thank you to a technician by clicking on the thumbs upwards the button under the post. You can even run amok and click on both buttons, .

  • How to get higher and second higher value of a line?

    Hello world

    I want more solid and second upper sal from emp in a line,

    Thank you

    Hello

    Whenever you have a problem, after the results you want.
    Always tell what version of Oracle you are using.

    Are you looking for this?

    HIGHEST_SAL SECOND_HIGHEST_SAL
    ----------- ------------------
           5000               3000
    

    If so, follow these steps:

    WITH     got_r_num     AS
    (
         SELECT     sal
         ,     ROW_NUMBER () OVER (ORDER BY sal DESC)     AS r_num
         FROM     scott.emp
    )
    SELECT     MAX (CASE WHEN r_num = 1 THEN sal END)     AS highest_sal
    ,     MAX (CASE WHEN r_num = 2 THEN sal END)     AS second_highest_sal
    FROM     got_r_num
    ;
    

    It works in Oracle 9 (and), but can easily be adapted for Oracle 8.1.
    From Oracle 11, you can also use SELECT... PIVOT.

    It is unclear how you want to handle links. Say there were only 3 rows, with 100, 200 and 200 sals. What do you consider being the second highest?

  • If I have the two LOV in the same table then how to connect when I select first and second LOV value also change?

    Mr President

    If I have the two LOV in the same table then how to connect when I select first and second LOV value also change?

    My two fields are FLOW AND DR_NAME

    FLOW = ACCT_ID

    DR_NAME = ACCT_NAME

    I created with success of LOV for these fields.

    First LOV gives acct_id in the debit field and second LOV gives the value of acct_name to dr_name.

    How can I report these lov, it's that when I change my acct_id then acct_name also change

    I have these two tables

    CREATE TABLE "NOM"  (
      "ACCT_ID" VARCHAR2(7) NOT NULL ENABLE, 
      "ACCT_NAME" VARCHAR2(50) NOT NULL ENABLE, 
      "O_BAL" NUMBER(13,2),
      CONSTRAINT NOM_PK PRIMARY KEY ("ACCT_ID")ENABLE
       
       );
    CREATE TABLE "VOUCHERDET" (
      "V_ID" VARCHAR2(9) NOT NULL ENABLE,
      "LINEITEM" NUMBER ,
      "DEBIT" VARCHAR2(7) , 
      "DR_NAME" VARCHAR2(50), 
      "CREDIT" VARCHAR2(7) , 
      "CR_NAME" VARCHAR2(50), 
      "PARTICULARS" VARCHAR2(100), 
      "AMOUNT" NUMBER(21,2),
    CONSTRAINT VOUCHERDET_PK PRIMARY KEY ("V_ID","LINEITEM")ENABLE, 
    CONSTRAINT PUR_SAL_LINE_POD_FK FOREIGN KEY(PROD_ID)
      REFERENCES PRODUCTS (PROD_ID)ENABLE,  
    CONSTRAINT VOUCHERDET_DEBIT_FK FOREIGN KEY ("DEBIT")
       REFERENCES "NOM" ("ACCT_ID") ENABLE, 
    CONSTRAINT VOUCHERDET_CREDIT_FK FOREIGN KEY ("CREDIT")
       REFERENCES "NOM" ("ACCT_ID") ENABLE,  
    CONSTRAINT VOUCHERDET_V_FK FOREIGN KEY ("V_ID")
       REFERENCES "VOUCHER" ("V_ID") ON DELETE CASCADE ENABLE
      );
    
    

    Concerning

    so, instead of this second ActId, choose ACCT_NAME:

  • I create a form based on two tables that have sequences also. When I create insert only row is inserted in the fields in table first and second fields of the table are empty. Why?

    Mr President.

    I create a form based on two tables that have sequences also. When I create insert only row is inserted in the fields in table first and second fields of the table are empty. Why?

    formdoubletables.png

    the page source is

    <?xml version='1.0' encoding='UTF-8'?>
    <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                    xmlns:f="http://java.sun.com/jsf/core">
      <af:panelFormLayout id="pfl1">
        <af:group id="Group">
          <af:inputText value="#{bindings.VoucherId.inputValue}" label="#{bindings.VoucherId.hints.label}"
                        required="#{bindings.VoucherId.hints.mandatory}" columns="#{bindings.VoucherId.hints.displayWidth}"
                        maximumLength="#{bindings.VoucherId.hints.precision}"
                        shortDesc="#{bindings.VoucherId.hints.tooltip}" id="it1">
            <f:validator binding="#{bindings.VoucherId.validator}"/>
            <af:convertNumber groupingUsed="false" pattern="#{bindings.VoucherId.format}"/>
          </af:inputText>
          <af:inputDate value="#{bindings.VoucherDate.inputValue}" label="#{bindings.VoucherDate.hints.label}"
                        required="#{bindings.VoucherDate.hints.mandatory}"
                        columns="#{bindings.VoucherDate.hints.displayWidth}"
                        shortDesc="#{bindings.VoucherDate.hints.tooltip}" id="id1">
            <f:validator binding="#{bindings.VoucherDate.validator}"/>
            <af:convertDateTime pattern="#{bindings.VoucherDate.format}"/>
          </af:inputDate>
          <af:inputText value="#{bindings.Credit.inputValue}" label="#{bindings.Credit.hints.label}"
                        required="#{bindings.Credit.hints.mandatory}" columns="#{bindings.Credit.hints.displayWidth}"
                        maximumLength="#{bindings.Credit.hints.precision}" shortDesc="#{bindings.Credit.hints.tooltip}"
                        id="it2">
            <f:validator binding="#{bindings.Credit.validator}"/>
          </af:inputText>
        </af:group>
        <af:group id="g1">
          <af:inputText value="#{bindings.Lineitem.inputValue}" label="#{bindings.Lineitem.hints.label}"
                        required="#{bindings.Lineitem.hints.mandatory}" columns="#{bindings.Lineitem.hints.displayWidth}"
                        maximumLength="#{bindings.Lineitem.hints.precision}" shortDesc="#{bindings.Lineitem.hints.tooltip}"
                        id="it3">
            <f:validator binding="#{bindings.Lineitem.validator}"/>
            <af:convertNumber groupingUsed="false" pattern="#{bindings.Lineitem.format}"/>
          </af:inputText>
          <af:inputText value="#{bindings.VoucherId1.inputValue}" label="#{bindings.VoucherId1.hints.label}"
                        required="#{bindings.VoucherId1.hints.mandatory}"
                        columns="#{bindings.VoucherId1.hints.displayWidth}"
                        maximumLength="#{bindings.VoucherId1.hints.precision}"
                        shortDesc="#{bindings.VoucherId1.hints.tooltip}" id="it4">
            <f:validator binding="#{bindings.VoucherId1.validator}"/>
            <af:convertNumber groupingUsed="false" pattern="#{bindings.VoucherId1.format}"/>
          </af:inputText>
          <af:inputText value="#{bindings.Debit.inputValue}" label="#{bindings.Debit.hints.label}"
                        required="#{bindings.Debit.hints.mandatory}" columns="#{bindings.Debit.hints.displayWidth}"
                        maximumLength="#{bindings.Debit.hints.precision}" shortDesc="#{bindings.Debit.hints.tooltip}"
                        id="it5">
            <f:validator binding="#{bindings.Debit.validator}"/>
          </af:inputText>
          <af:inputText value="#{bindings.Credit1.inputValue}" label="#{bindings.Credit1.hints.label}"
                        required="#{bindings.Credit1.hints.mandatory}" columns="#{bindings.Credit1.hints.displayWidth}"
                        maximumLength="#{bindings.Credit1.hints.precision}" shortDesc="#{bindings.Credit1.hints.tooltip}"
                        id="it6">
            <f:validator binding="#{bindings.Credit1.validator}"/>
          </af:inputText>
          <af:inputText value="#{bindings.Particulars.inputValue}" label="#{bindings.Particulars.hints.label}"
                        required="#{bindings.Particulars.hints.mandatory}"
                        columns="#{bindings.Particulars.hints.displayWidth}"
                        maximumLength="#{bindings.Particulars.hints.precision}"
                        shortDesc="#{bindings.Particulars.hints.tooltip}" id="it7">
            <f:validator binding="#{bindings.Particulars.validator}"/>
          </af:inputText>
          <af:inputText value="#{bindings.Amount.inputValue}" label="#{bindings.Amount.hints.label}"
                        required="#{bindings.Amount.hints.mandatory}" columns="#{bindings.Amount.hints.displayWidth}"
                        maximumLength="#{bindings.Amount.hints.precision}" shortDesc="#{bindings.Amount.hints.tooltip}"
                        id="it8">
            <f:validator binding="#{bindings.Amount.validator}"/>
            <af:convertNumber groupingUsed="false" pattern="#{bindings.Amount.format}"/>
          </af:inputText>
        </af:group>
        <f:facet name="footer">
          <af:button text="Submit" id="b1"/>
          <af:button actionListener="#{bindings.CreateInsert.execute}" text="CreateInsert"
                     disabled="#{!bindings.CreateInsert.enabled}" id="b2"/>     
          <af:button actionListener="#{bindings.Commit.execute}" text="Commit" disabled="#{!bindings.Commit.enabled}"
                     id="b3"/>
          <af:button actionListener="#{bindings.Rollback.execute}" text="Rollback" disabled="#{!bindings.Rollback.enabled}"
                     immediate="true" id="b4">
            <af:resetActionListener/>
          </af:button>
        </f:facet>
      </af:panelFormLayout>
    </ui:composition>
    
    
    
    

    Concerning

    Go to your VO Wizard, select the tab of the entity and to check if both the EO is editable or not.

    See you soon

    AJ

  • I need ios 10 beta 3 and 4 and 5 and 6 and 7 and 8

    I need ios 10 beta 3 and 4 and 5...

    They are not available.  Maybe if you are a registered developer, you can ask them, I don't know. But to anyone else they are not made available to Apple now that the public version has been issued.

  • I changed my beta version updated channel by mistake and it upgraded to a beta version, and now there is no option to restore.

    I changed my beta version updated channel by mistake and it upgraded to a beta version, and now there is no option to restore.

    You can only change the update channel if you uninstall Firefox and remove the Firefox program folder or install a beta version or release that copies a file new channel - prefs.js. Update Firefox never changes the update channel. Only a full installation will do it.

  • Help! My story disappeared on the old version and the beta version and it won't keep my story saved now.

    So after I leave this page Firefox will not know that I was never to support.mozilla.com, nor is he knows that I've never been on Facebook, or will he forget not all long URLS which I rely on it for. My story is gone and it will not keep track of my new story either. I do not use Private Browsing. In addition, Internet Explorer doesn't have the problem, so I never really use Internet Explorer. (The two browsers Firefox have the problem).

    This may be a problem with the places.sqlite file that stores the bookmarks and history.

    Be sure not to use the same profile with different versions of Firefox folder, because it's asking for problems.

    If you have Firefox beta 4 and Firefox 3.6.x version then you must use a separate profile for each version.

    See:

  • Everytime I open Firefox 4.0 Beta 6 and try to connect on websites such as Hotmail, Facebook, RuneScape etc it won't let me... Help?

    Whenever I open Firefox 4.0 Beta 6 and trying for a long time on websites such as Hotmail, Facebook RuneScape etc it won't let me... I think it's frusrtrating and annoying because I can't use Firefox 4.0 Beta 6. It works on other accounts, excluding mines - what is this shit rigged or something? I have to use Google Chrome and Safari shit since he messed up on two of my computers... Here is what it says when I double-click the shortcut: "could not initialize the safety component of the application. The most likely cause is problems with the files in the directory of the profile of your application. Please check that this directory has no restriction of read/write and your hard disk is not full or close to full. It is recommended that you exit the application and correct the problem. If you continue to use this session, you may see incorrect application behavior when you access security features. "Even if it shows the way to help - can you love, he dumb down for me?

    ALSO, here's what he says when I go to http://runescape.com - it says: an error occurred during a connection to www.runescape.com:443.

    Cannot connect securely because the SSL protocol has been disabled.

    (Error code: ssl_error_ssl_disabled)

    See the problems related to the error message "secure connection failed"

    Create a new profile exclusively for version 4.0 beta and create a shortcut on the desktop with Pei 'profile' attached to the target to launch this profile.

  • Is the app for Better Homes and Gardens Cookbook for Mac still available?

    I have the app for Better Homes and Gardens Cookbook, but it works on my iPad.  I want it on my Macbook Pro.  How to do it?

    HOW is it that so many things are available on the iPad but not on Mac computers?

    You can try to contact the developers of the versions of iOS apps and ask them if they have plans to make a Mac version of them

  • How to set the clock for the hours, minutes, and seconds with Windows XP

    How to set the clock for the hours, minutes, and seconds with Windows XP

    I don't know of your question.  If you ask how to show the clock in the tray system with hours, minutes and seconds, then download & run "Tclock Light".  Windows will not natively display the seconds.

    TClock Light: <> http://homepage1.nifty.com/kazubon/tclocklight/index.html >

    HTH,
    JW

  • is it possible that a single screen will work with the slider and second focus mode

    Hello

    can you please tell me is it possible that a single screen will work with cursor mode and second focus mode.

    Thank you

    Hello

    I don't think that it is possible to change the mode of the development of your application outside of in the config.xml file.

    A custom extension may be able to do this, but I have not seen anyone this yet.

  • How to add days, hours, minutes and seconds to a date?

    Hello

    I have the following problem.
    Saw 4 integers D, H, M, and S (each of them can be negative) and a date Da, I want to add days D, H hours, M minutes and seconds of S date Da.
    For example, if
    Da= to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss'), and D = 3, H = -2, M = 20 and S = -12, 
    This means that I want to add 3 days, -2 hours, 20 minutes and -12 seconds to the date Da, and the new date must be in the following date:
    to_date('01/07/2011 13:10:23','dd/mm/yyyy HH24:mi:ss') 
    Is it possible to write a query for this problem or should I use PL/SQL?

    Thank you.

    There is no need of PL/SQL

    SQL> alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS';
    
    Session altered.
    
    SQL> var d number
    SQL> var h number
    SQL> var m number
    SQL> var s number
    SQL> exec :d := 3; :h := -2; :m := 20; :s := -12
    
    PL/SQL procedure successfully completed.
    
    SQL> select to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss')
      2     + :d
      3     + (:h / 24)
      4     + (:m / 24 / 60)
      5     + (:s / 24 / 60 / 60)
      6  from dual;
    
    TO_DATE('28/06/2011
    -------------------
    01/07/2011 13:10:23
    
  • MP3, AS3 beta 3 and strangeness of Mac

    I'm looking for help tracking down the source of a problem that has me baffled.

    I'm learning AS3 on a Mac, compiling with mxmlc via the Terminal. I like some of the demos of the spectrum Visualizer I ran and am determined to understand. A developer of a local user group has generously shared with me in order to study the code.

    I got it with the beta 2 SDK, except that it doesn't seem to be able to extract the ID3 info. Maybe we were hoping it was a bug that would be fixed in Beta 3 but rather things beta 3 is worst.

    After that correction of syntax changes between beta 2 and 3 code that worked in beta 2 has made the Visual elements to the right stage, but he refused to play the MP3 resource. I can look in Safari's activity window as the flow of data in the browser. The player has a progress bar of download, which works and which signals that data to load in the browser. But would not play music.

    The original author of the code sent me an updated, who works for him (developing on a PC). I copied and pasted, nothing else that my MP3 file name change and although it compiled without complaint he didn't play music (on my Mac or PC). I sent him code that does not play for me and he DID when he compiled on his system (Windows PC).

    I made a completely minimal swf that not trying to do anything fancy at all - just load the resource and read it. Same thing: the flow of data to the browser, but no music is playing.

    At this point, I tried replacing it with another MP3 file. Suddenly, he played! Thinking it was a problem with the MP3 first (even though this MP3 worked fine using the beta 2 release), I tried a third. He has NOT played! All three of these files worked in various pre - AS3 Flash mp3 players, I've built. All three tracks play in quicktime when addressed directly. I can't for the life of understand me why don't work two of the three files of MP3 Player 9 on a Mac.

    This context has led my more experienced friend to suspect there could be some aspects of the flex-config file. XML that is not correct in my environment, but I have no idea where to begin the search in this file. I have not modified the flex-config. XML provided with Beta 3 SDK. I'm not passing all the arguments in the Terminal other than the path to mxmlc and the ActionScript source file.

    And try to get out of the artist id3 and songName values STILL does not work! I would be grateful if anyone has information about where to begin the search. Thank you.

    Steve

    Hi Steve,.

    Thanks for posting the sample files. You can delete this data now.
    The issue looks like a bug. I will file a bug on the issue, which hopefully should be fixed in the next version.
    As a solution until then, you can open the MP3 file which do not show the ID3 in winamp, press "alt + 3" for the file Info dialog box, just add a space somewhere and press the update button.

    Thanks for letting us know of the issue,
    Anjali Bhardwaj
    Adobe Flex SDK Development Team

  • Max amount of memory

    I was wondering what is the maximum amount of memory, you can add to windows xp. I get the "WARNING os paged pool memory low" so I need to upgrade, but I do not know the max that I can put in. I have 4 GB and I would get 8Gb

    Physical memory limits: Windows XP

    The following table specifies the physical memory limits for Windows XP.

    Version Limit in 32-bit Windows Limit in 64-bit Windows
    Windows XP

    4 GB

    128 GB

    Windows XP Starter Edition

    512 MB

    Does not apply

    Published on April 25, 2005 byMicrosoft Edition of Microsoft Windows XP Professional x 64 is a variant of the Windows XP operating system for computers personal x 86-64 .

    Windows XP Professional x 64 edition uses version 5.2.3790.1830 of core files, the same version used byWindows XP 64-bit edition 2003 and Windows Server 2003 SP1, because they were the latest versions during the development of the operating system. It is designed to use the expanded memory 64-bit address space provided by the x 86-64 architecture.

    The main advantage of switching to 64 bit is the maximum increase of the system totalmemory (RAM). Windows XP 32 bit is limited to a total of 4GB, which is, by default, evenly distributed between theWindows kernel and application use. Using the/3 GB switch in the boot.ini file will force Windows to limit the kernel to the superior of 1 GB and offers up to 3 GB for applications. Windows XP x 64 can support much more memory; Although the theoretical limit than a 64-bit computer memory can handle about 16 exbibytes (16 billion Gibabytes), Windows XP x 64 is currently limited to 128 GB of physical memory and 16-bit virtual memory. Microsoft argues that this limit will be increased to improve the hardware capabilities

    Published on April 25, 2005 byMicrosoft Edition of Microsoft Windows XP Professional x 64 is a variant of the Windows XP operating system for computers personal x 86-64 .

    Windows XP Professional x 64 edition uses version 5.2.3790.1830 of core files, the same version used byWindows XP 64-bit edition 2003 and Windows Server 2003 SP1, because they were the latest versions during the development of the operating system. It is designed to use the expanded memory 64-bit address space provided by the x 86-64 architecture.

    The main advantage of switching to 64 bit is the maximum increase of the system totalmemory (RAM). Windows XP 32 bit is limited to a total of 4GB, which is, by default, evenly distributed between theWindows kernel and application use. Using the/3 GB switch in the boot.ini file will force Windows to limit the kernel to the superior of 1 GB and offers up to 3 GB for applications. Windows XP x 64 can support much more memory; Although the theoretical limit than a 64-bit computer memory can handle about 16 exbibytes (16 billion Gibabytes), Windows XP x 64 is currently limited to 128 GB of physical memory and 16-bit virtual memory. Microsoft argues that this limit will be increased to improve the hardware capabilities

Maybe you are looking for