How to use several aggregate functions in a single request

Hi all

The output will give first_name, last_name, max (salary), min (salary) and the output will be wise Department. Of the employees in a single query table


result will be:
first_name: last_name. Max (salary): min (salary)

Hello

SELECT first_name,last_name,
       MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) "Lowest",
       MAX(sal) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) "Highest"
FROM   emp
ORDER BY deptno, sal;

Tags: Database

Similar Questions

  • How to use the @accum function in the calculation script

    Dear all.

    I'm new in essbase - calculation script so don't know how to use the @accum function.

    I want the aggregation value of child to parent

    Hierarchy

    Product

    100 > Storage Dimensions marked as stored (marked as intentionally as I want to calculate the value using the calculation script)

    100. 10 (+)

    100-20 (+)

    100-30 (+)

    I'm trying calculation Script

    100 = @Accum (@children("100"), jan: Feb);

    It works when I use below

    100 = @Accum("100-10",Jan:Feb);

    Error:-number of Dimensions [1] does not match number of gen/lev [3] office [@Dim]

    Don't know how I can roll up to an aggregate value of all the members of the child to the parent.

    Error.PNGhierachy.PNG

    you do this more difficult it must be. If you want to accumulate up to 100 then you could just make your calc

    '100 '.

    but that would be only 100, to make the OU any dimension would

    AGG (Product);

    Or better yet

    AGG (Product, Market);

  • How to use several adf 12 shape and insert the form data in to table during the click on "submit" button

    How to use several adf 12 shape and insert the form data in to table during the click on "submit" button. Can we use several form from adf or not?

    Make sure that you dragged the VO based EO.

    Also make sure that the VO attributes based EO Updatable property.

    The query according to VO is used only to add LOV to the column of the original VO ModelId.

    See you soon

    AJ

  • How to use the NVL function in decoding?

    Hi all

    How to use the NVL function in decoding?

    SELECT Decode (Sign (sum (nvl (7), 0)-nvl (sum (5), 0)), - 1, 0, (sum (nvl (7), 0)-nvl (sum (5), 0)) QTY)

    of the double

    Thank you

    You should not do that...

    Greatest (NVL (Sum (Quantity), 0)-NVL (SUM (quantity_received), 0), 0) AS qty_arrival

    will do the same

    HTH

  • Oracle: how to use the max() function in expression box

    How to use the max() function in the case where expression, please explain with an example

    Hope this helps and should be explicit

    with t as
    (select 1 col,100 col2 from dual union
    select 2 ,100 from dual union
    select 2 ,200 from dual union
    select 3,100  from dual union
    select 3,200  from dual  )
    select col, case when max(col2)=100 then 'with 100 range'
    when  max(col2)=200 then 'with 200 range' end  from t group by col
    
  • How to use the goto function?

    How to use the goto function in indesign javascript?

    my script begins by chekcing if the input files are present or not... If one of the input files is not present, I want the n function put an end to the operation in the display of the message tht file exists... I was wondering to use goto for tht... then how to use it? or is there an alternative to that?

    GoTo is generally frowned upon by the programmers.

    The only legitimate use of goto is when you need to escape from a nested loop.

    If you need to jump into a routine, use break or simply in return from the current function.

    The model currently used by the SDK looks like this:

    do
    {
         if(condition1 == false)
              break;
         if(condition2 == false)
              break;
         if(condition3 == false)
              break;
         doSomethingReallyCool();
    }while(false);
    

    'break' the jumps at the end of the do / while loop that always comes out when you reach the end of it (while (false))

    Substances

  • How to use the TRUNC function with dates in the expression builder in OBIEE.

    Hello
    How to use the TRUNC function with dates in the expression builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.


    Thanks in advance

    Use it instead:
    TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE)

  • How to combine several pdf files into a single pdf file of document

    How to combine several pdf files into a single pdf file of the document?

    IF you use a Mac Version (I guess that even for the PC version) you and use the new handset functionality.

    1. To use Acrobat open without opening a PDF and go to file menu choose combine PDF.
    2. A small window opens
    3. Look for the files to combine
    4. Drag the window and gout.
    5. Search for the following file and repeat
    6. Drag the files to correct the order.
    7. Rename and save the PDF

    Its actually easier than using insert pages.

  • File navigation on OSX problem - how to use a filter function?

    I work with file navigation atm using the JSX file objects and the openDlg method and quite frankly, it drives me crazy.

    He has a crazy person decided it was a good idea to have the filter flag on the totally different openDlg method to Win and OSX? Under windows, you use a string for filtering, OSX he wants is a function!

    I checked the documentation and also searched this forum and I can't even find an example of how to set up so that it works for Windows and OSX?

    OK, so I found the syntax, but it still does not make sense.

    fileMask = function(file){file.name.match(/\.psd$/i) ? true:false;}
    


    Here we have the psd extension hardcoded in the regular extension. But what happens if we want it to be a variable? And what happens if t he file does not yet exist.

    Basically I want is the user of:
    Navigate to a folder

    Set a file name

    record.

    The extension type must be locked!

    Compared to the way of windows to do things, the way OSX to use a filtering function is too complex, absurd and downright annoying!

    EDIT: I also discovered that you can not write a file on OSX name unless the file already exists. Come on! Is this the type of dialogue hurt or something?

    Here is my script to request a file that handles the differences Win/Mac

    function isWindows() {
      return app.systemInformation.indexOf("Operating System: Windows") >= 0
    }
    function isMac() {
      return app.systemInformation.indexOf("Operating System: Mac") >= 0
    }
    function promptFile(filter_extension) {
      var filter = null
      if (isMac()) {
           if (filter_extension) {
                var filter_regex = new RegExp("[^\.]*\."+filter_extension+"$")
                filter = function (file_entry) {
                     return filter_regex.test(file_entry.name)
                }
           } else {
                filter = function () { return true }
           }
      } else if (isWindows()) {
           if (filter_extension) {
                filter = filter_extension.charAt(0).toUpperCase() + filter_extension.slice(1)+"-files:*."+filter_extension
           } else {
                filter = "All files:*.*"
           }
      } else {
           filter = null
      }
      var f = File.openDialog("Select your file", filter, false)
      if (f) {
           return f.fsName.replace(/\\/g, "/") // sanitize to forward slash
      }
    }
    }
    
  • How to use the add_months() function in a mapping?

    Hello

    I have a variable in ODI with a date and I need to add another variable to add 'x' months...

    How can do that?

    Thank you

    If you say you have variable1 organise a date for example 01/01/2015 and variable 2 holding a certain number of months for example 7?

    If so in your mapping expression simply use the date functions available to your database technology (step/target) and replace the variable in the function

    that is for Oracle your mapping would be ADD_MONTHS (#Variable1,Variable2of #)

  • How to use the NVL function to a parameter with comma delimited values

    Gurus,

    It is confusing to me.  I am trying to use the NVL function, but the setting that I'm passing in my cursor contains multiple values with commas.  The NVL function is confused when analyzing the values.

    'Where' cursor clause...

    and nvl (sn.c_attribute1,'x@#$%') in nvl (p_desig,'x@#$%'( )

    translated parameter values...

    and nvl (sn.c_attribute1,'x@#$%') in nvl ('SPRT''GOOD' 'BAD' 'x@#$%') -NVL does not parse the value correctly

    Any idea on how to get NVL recognize 'x@#$%' , if p_desig is null?

    Thank you

    Scott

    HI, Scott.

    Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

    My best guess, based on what you posted bone is present, that your problem is discussed in the following:

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

    http://www.Oracle-base.com/articles/Misc/DynamicInLists.php

  • How to include an aggregate function in a function user_defined

    I created the following function to validate the value of the commission of a table I created



    create or replace function validate_comm (number v_comm)
    return a Boolean value
    is
    VCOMM employeesCopy.commission_pct%type;
    Start
    Select max (commission_pct) in vcomm
    of employeesCopy
    where commission_pct = v_comm;
    If v_comm < vcomm then
    Returns true;
    on the other
    Returns false;
    end if;
    end;



    the service was created successfully, but when I run it as follows:



    Start
    If validate_comm (0.0) then
    dbms_output.put_line ('True');
    on the other
    dbms_output.put_line ('False');
    end if;
    end;



    He always gives the wrong data, even if the maximum value of commission_pct in my table is 0.4 but I always wrong whenever I run the function. Why? and is it true to put the aggregate function in the select statement?

    Hello

    If you don't want to UPDATE to each row of the table, and then add a WHERE clause to your UPDATE statement.

    You can do what you want without procedures or user-defined functions:

    update      employeesCopy
    set      commission_pct      = v_comm;
    where     commission_pct     < (
                        SELECT     MAX (commission_pct)
                        FROM     employeesCopy
                     );
    

    You didn't post a test version of your table, so I can't really test this.

    There are good reasons to want to do this in PL/SQL. If you have one, you can write a procedure reset_comm that executes the UPDATE above statement.
    If you want to make the statement to UPDATE a bit simpler by writing a function defined by the user (even if the net result is more coding and complexity more) so I think that a function takes no arguments and returning the MAX (commission_pct) would be more useful than something that had a fight and has returned a value depending on whether the qualified argument one line update , but if you don't want such a function, its arguments must be the values to take into account when it decides whether a line is updated. Should what value (s) on each line you consider in deciding if this line is up to date? If it's just commission_pct, then your procedure reset_comm might look like this:

    create or replace procedure reset_comm (v_comm number)
    is
    begin
         update      employeesCopy
         set      commission_pct = v_comm;
         where     validate_comm (commission_pct)     = 'OK';
    end;
    
  • How to use several collaborators channel of BBM BBM?

    He said we can use several collaborators for the channel of BBM surveys for the new update...

    http://press.BlackBerry.com/press/2015/BBM-introduces-new-ways-to-customize-your-chat-experience.htm...

    but I can't find any source to the place where to use it?

    Thank you

    Jay

    Channel of BBM of multiple contributors: BBM channels now supports several collaborators channel via the web client; makes it easier for the owners of BBM channel 1 million to manage and publish new content.

    The web client:

    Access your channel of BBM through BBM Channel Manager

  • How to use several different sections of the same clip in the timeline?

    Hey, I used this tutorial as a reference for editing. I have my own equipment I want change, which includes several takes different. Is it possible to use several different sections of the same clip in the timeline? You know, like the good part of a certain record keeping. I appreciate any assistance. Thank you

    Post edited by: Kevin Monahan

    Reason: changed the title of best research opportunities

    I prefer to put the clip in the Source monitor Panel, then set the points and exit. From there you can simply drag the section of the element in the sequence.

    Or, you can make a subelement, the section will have a distinct element in the bins in the project Panel. You should always keep the original material, but now you can have real subitems to work if you prefer.

  • How to use the Substring function with Case statement.

    Hi all

    I have a requirement where I have to use the substring function on the ground for the report criteria.
    FOR EXAMPLE
    I branch domain name where I have all the information of the branch names, now some of the branch names are too large with an extension after the name.
    now I want substing it, but the length of characters varies for each branch.
    so is it possible where we use a box where we can define if the character of name plug exceed a value then he substing with this length.

    Try something like this:

    LENGTH WHEN CARTER (tablename. Branch_Name) > n THEN SUBSTRING (...) Of ANOTHER tablename. Branch_Name END

    where n is the number of characters that you want to start the break.

Maybe you are looking for