Select the emp with a maximum salary for each hr.emp manager_id

Hello
Can someone help me to do this without doing any partitioning or analytical f:

Select the emp with a maximum salary for each hr.emp manager_id.

HR. EMPLOYEES Table Description: =.
EMPLOYEE_ID
FIRST NAME
LAST_NAME
HIRE_DATE
JOB_ID
SALARY
COMMISSION_PCT
MANAGER_ID
DEPARTMENT_ID

TX, all the guys
Mario

Hi, Mario,.

Here's one way:

SELECT       *
FROM       hr.employees
WHERE       (manager_id, salary) IN (
                                      SELECT    manager_id
                          ,               MAX (salary)
                          FROM     hr.employees
                          GROUP BY  manager_id
                               )
;

mario17 wrote: Hi,
Can someone help me to do this without doing any partitioning or analytical f:

Do you mean analytical functions?
Why you don't want to use the analytical functions? Analytical functions, permitting the simpler, more robust and more effective to achieve these results, wouldn't you want that?

Tags: Database

Similar Questions

  • Select the period 30 sec by random for each hour

    Hello
    Is it a good cool way to delay select 30 sec for each hh24, ideally that should be selected at random 30 sec for each hour.

    for now I use it because I 1.24 LOOP and specific (non-random) selection interval.

    Or in other words is there any random function that may generate number BUT in the predefined example limits (0 thru 3570) (3 600 s - 30 s)

    SELECT...
    WHERE INDATE WITH (D1 (D1 + 30/86400))

    TX
    T

    Hello

    TRUNC (dbms_random.value (0, 3570))
    

    Returns a random integer between 0 and 3569.
    So if dt is an Oracle DATE, indicating the beginning of time,

    dt + ( dbms_random.value (0, 3570)
         / (24 * 60 * 60)
         )
    

    will be the start of a period of 30 seconds which is entirely within this time, as shown in this query:

    ALTER SESSION     SET NLS_DATE_FORMAT = 'HH24:MI:SS';
    
    WITH     got_hrs     AS
    (
         SELECT  TRUNC (SYSDATE) + ( (LEVEL - 1)
                                / 24
                          )     AS hr
         FROM    dual
         CONNECT BY     LEVEL <= 24
    )
    SELECT    hr
    ,       hr + ( TRUNC (dbms_random.value (0, 3570))
                                 / (24 * 60 * 60)
                          )     AS period_start
    FROM       got_hrs
    ORDER BY  hr;
    

    Typical power:

    HR       PERIOD_S
    -------- --------
    00:00:00 00:36:35
    01:00:00 01:21:00
    02:00:00 02:12:55
    ...
    21:00:00 21:19:24
    22:00:00 22:54:55
    23:00:00 23:04:59  
    

    Dbms_random is an integrated package, but you do not have privileges to use it. Otherwise, log in as SYS and grant EXECUTE privileges to you or to the PUBLIC, or have your DBA to do.

  • Select the lines with the maximum value for a date where another column is different from 0

    Hello

    I need to write a query on a table (called DEPRECIATION) that returns only the rows whose date maximum (PERENDDAT_0 column) for a specific record (identified by AASREF_0), and where the other column in the table called DPRBAS_0 is different from 0.

    If DPRBAS_0 is equal to 0 in all the lines of a specific record, then return the line with date maximum (PERENDDAT_0 column).

    To be clearer, I give the following example:

    Suppose we have the following data in the table of DEPRECIATION:

    AASREF_0 PERENDDAT_0 DPRBAS_0
    I2011001074331/12/20150
    I2011001074331/12/20140
    I2011001074331/12/20130
    I2011001085612/31/20160
    I2011001085631/12/20150
    I2011001085631/12/2014332
    I2014001223812/31/2016445
    I2014001223831/12/2015445
    I2014001223831/12/20140

    The query must return only the following lines:

    AASREF_0 PERENDDAT_0 DPRBAS_0
    I2011001074331/12/20150
    I2011001085631/12/2014332
    I2014001223812/31/2016445

    Thanks a lot for your help!

    This message was edited by: egk

    Hello Egk,

    The following query works for you.

    SELECT AASREF_0, PERENDDAT_0, DPRBAS_0

    FROM (SELECT AASREF_0,

    PERENDDAT_0,

    DPRBAS_0,

    ROW_NUMBER)

    DURING)

    AASREF_0 PARTITION

    ORDER BY

    CASE WHEN DPRBAS_0 <> 0 THEN 1 OTHER 0 END DESC,.

    PERENDDAT_0 DESC)

    RN

    DEPRECIATIONS)

    WHERE rn = 1

  • Select the line with the smallest Beach

    Hello
    I am trying to build a complex query...
    He must select the line with the inner range...

    I'll explain for example:
    Location of poolsize ID value
    1 32 8
    2 40 6
    3 42 8
    4-36-3

    I want to select the line where the fork between value and value + poolsize is shared also with the other location...
    so:
    1 is 32-40 (in A place)
    2 is 40-46 (in place)
    3 is 42-48 (location B)
    4 is 36-39 (at location B)

    4 is located at 1 (and there are different places...) so sql must return to the fourth line.

    Any help will be appreciated!

    Thank you
    fcbman

    Hello

    fcbman1899 wrote:
    Hello
    I am trying to build a complex query...
    He must select the line with the inner range...

    I'll explain for example:
    Location of poolsize ID value
    1 32 8
    2 40 6
    3 42 8
    4-36-3

    Whenever you have a problem, please post CREATE TABLE and INSERT statements for your sample data, in order to let the people who want to help you re-Ridge the problem and test their ideas.
    See the FAQ forum {message identifier: = 9360002}

    I want to select the line where the fork between value and value + poolsize is shared also with the other location...
    so:
    1 is 32-40 (in A place)
    2 is 40-46 (in place)
    3 is 42-48 (location B)
    4 is 36-39 (at location B)

    4 is located at 1 (and there are different places...) so sql must return to the fourth line.

    To find all the rows that are within the range of at least one other line with another location:

    SELECT     *
    FROM     table_x  m
    WHERE     EXISTS (
                 SELECT  1
                 FROM        table_x
                 WHERE   location          != m.location
                 AND        value          <= m.value
                 AND        value + poolsize     >= m.value + m.poolsize
                )
    ;
    

    When you talk of the "" * most * inner range ", do you mean that you might have another line, such as"

    INSERT INTO table_x (id, vlue, poolsize, location) VALUES (5, 37, 1, 'C');
    

    which is inside the range of id - 4, and that's why you wouldn't have id = 4? If so, include examples in the results and data sample yout. You can do this with a query CONNECT BY, or, depending on your version of Oracle, a WITH recursive clause.

  • If I click on an email link in a web page instead of an empty message is opened I still get noise toward the top of the screen with a log-in for googlemail. I don't have and won't have a googlemail account. I just want to be able to send e-mail messages b

    If I click on an email link in a web page instead of an empty message is opened I still get noise toward the top of the screen with a log-in for googlemail. I don't have and won't have a googlemail account. I just want to be able to send e-mail messages by using Outlook.

    See this article.

    http://support.Mozilla.com/en-us/KB/changing+the+e-mail+program+used+by+Firefox

  • I look integrated in the block of the legend of slide show, a widget like "Accordion" for, with one click, or by the way with the mouse, open a new caption for each photo. I tried with 'Accordion' Muse, it does not work. I haven't tried to copy and paste,

    Issue.

    I look integrated in the block of the legend of slide show, a widget like "Accordion" for, with one click, or by the way with the mouse, open a new caption for each photo. I tried with 'Accordion' Muse, it does not work. I haven't tried to copy and paste, but no result. The widget disappear into the legend of block. disappear. Do you have a solution?

    Thank you

    Loïc

    Accordion Panel tabs should, with click and open the container.

    Please provide the url of the site where it does not, also if you can provide an example where we can see the exact action, then it would help us.

    Thank you

    Sanjit

  • Hi, how do I change the orientation of the page with headers and footers for facing pages

    Hello

    How to change the orientation of the page with headers and footers for facing pages in CS5

    Turning the page is only for the formatting of data - the page is not literally transformed for printing.

    In most print even if the pages of a book are enabled for the landscape, the header and the footer are still in the same position.

    If you need pages in landscape mode with headers and footers in a different location - you need to do these pages in the section "Master Pages" of the Pages panel

    Then apply these new Master Pages to the pages in your document.

    http://helpx.Adobe.com/InDesign/using/master-pages.html

    Note - it is not usual to have a different orientation for the headers and footers.

  • How to acquire of various AI channels simultaneously with a different range for each of them?

    How to acquire of various AI channels simultaneously with a different range for each of them?

    In LabView, I found some examples but in C it is not seem to be any.

    Or you can add channels one by one with individual instructions: the follwing code compilation and runs without error on vitual DAQ hardware:

    ERR = DAQmxCreateTask ("", &taskH); ")
    ERR = DAQmxCreateAIVoltageChan (taskH, ' Dev1/ai0', 'AI0', DAQmx_Val_Cfg_Default,-5,0, 5.0, DAQmx_Val_Volts, "");
    ERR = DAQmxCreateAIVoltageChan (taskH, ' Dev1/ai1', 'AI1', DAQmx_Val_Cfg_Default,-10,0, 10.0, DAQmx_Val_Volts, "");
    DAQmxStartTask (taskH);
    ERR = DAQmxReadAnalogF64 (taskH, 5, 10.0, DAQmx_Val_GroupByChannel, val, 10, & read, 0);
    DAQmxClearTask (taskH);

  • How to watch two clips at the same time on the other, with an opacity of 50% each.

    How to watch two clips at the same time on the other, with an opacity of 50% each. It is confirmed that the position of the object even two clips of mergers.

    Thank you

    PPut a clip on top of another in the timeline panel. In the video Inspector reduce the opacity of the clip on top.

  • I have 2 blogs on my site, I need to customize the layout of Blog Post details for each diff?

    I have 2 blogs on my site, I need to customize the layout of Blog Post details for each diff?

    Hello

    Unfortunately, it is not possible to have multiple layouts of details for your blog by site, at this point.

    Kind regards

    -Sidney

  • Select the list with a shipment does not save to the database

    OK, I have a form with several fields (text, radiobox, selection list, display text). I have one of these lists of selection fill a display in the text field. When I chose a selection of the selection list, she filled the screen in the text field with the correct information but erased all the other information that was the inscription in the other fields. I searched the forum and found that the selection list should be a selection with mailing list and the branch page on itself, which works, but now these 2 fields information is not saved in the database. All other fields are saved, but not both. Anyone know what im missing? Thank you

    Deanna

    Hi Deanna,
    First the display as a text cannot insert data into the database. It can only display data from database. I guess you do not want the user to enter these areas, and that's why you use display as text field.

    There is a good way to resolve this situation. Say, you have 3 select list P1_ITEM1, P1_ITEM2, P1_ITEM3 in your page. For the change of P1_ITEM1 the screen Select the list and the LOV type in your query, assuming you want the value to be retrieved from a table. Therefore, type-

    Select emp_id, ename from emp;

    type the default value and null -1 and display null YESvalue. Make sure that under the type of source, you have the selected with the correct name database column.
    for P1_ITEM2 to the section LOV retype your query - i.e.

    Select mng_id, executive pay where emp_id = NV('P1_ITEM1') or NV ('P1_ITEM1') = 1

    Basically, this statement updating the data in the list select second after the first selection. type the default value and null -1 and display null YESvalue. Make sure that under the type of source, you have the selected with the correct name database column.

    Do the same for the third. It should work fine.

    I hope this helps.

    Kind regards

    Pascal M
    http://Tajuddin.whitepagesbd.com

  • Select the label with VI Server/scripts

    I am trying to flush out my script code - and one of the functions I did auto pulls the focus of controls recently interrupted/indicators LABEL on the FP - I want to be able to select the text of the label - and I thought it was possible with VI Server Label.Selection.  I use another VI to take Ref VI of VI I am tracking to get the last control on the PC using the script to browse function - that part works fine.

    Label.Selection does not work, even when I set immediately KeyFocus = TRUE before the Label.Selection property.  I even inserted a frame VIFrontPanel.IsForemost is TRUE for the target VI before asking the KeyFocus for control...

    I checked that the target VI is slowed DOWN by reading the State of the VI.

    OBJECTIVE: I try to imitate the selection of the entire label that happens when you drop a new control.

    Any idea would be appreciated.  I've posted on the Board of Scripting - but do not get any response.

    On my Windows machine I would probably use a little trick of mouse function using user32.dll.

    Here, I simply select the first control, place the cursor in the center of the label and the false double click.  Then I move the cursor to the lower right.

  • Select the problem with expressions

    Hello

    I use Teststand 4.0 and a frustrating problem with the Select Case statements.

    I have attached a sequence that shows the problem.

    A loop from 0 to 10.

    The select case statement should decide which box 3 instructions corresponds to the expression and a message box is displayed.

    However the Basic program reacts as expected.

    First, he made his entry with a value of 0, it goes to the > 7 stated case.

    The second time, he enters the loop with a value of 1, it will correctly to the<3 case="">

    The other values of 2 to 10 enter no case statement.

    Is this a bug in TS 4?, or I do something wrong?

    Thank you

    Mike

    The problem is that you compare the Locals.New_Val of the Locals.New_Val property.< 3". ="" if="" those="" two="" properties="" match,="" then="" it="" will="" execute. ="" if="" you="" wanted="" that="" particular="" case="" to="" execute="" when="" locals.new_val="" is="" 0,="" you="" would="" just="" type="">

    Unfortunately there is no way to have multiple cases of a single block of code.

    In C, you could do it like this:

    Switch (newVal)

    {

    case 0:

    case 1:

    case 2:

    do something

    break;

    case 3:

    case 4:

    case 5:

    case 6:

    case 7:

    do something else

    break;

    etc...

    }

    Even in C, it's awkward, and you would probably do the following instead:

    If (newval<>

    do something

    Else if (newval<>

    do something else

    on the other

    do something else

    The reason why it works in TestStand, is that expressions will try to automatically convert types if she can do it.  false is logically equivalent to 0 and true, it is logically equivalent to 1, so what you are really comparing to in your case statement is your property (Locals.New_Val) to a Boolean expression that evaluates to 0 or 1.  It is certainly not obvious when we look at, but at least, this explains why it happens.  Another way, you could do this is to change "Point to compare" step of the 'True' selection, which will each case in order to compare the expression of the value 'true '.  I still recommend a structure if/else if/else for this kind of problem because it's easier to read, but it is possible to do what you want in this case with a select / box.

    P. Allen

    NEITHER

  • Select the query with the level line list where the clause

    Hi all

    I am creating a tabular presentation based on a SQL query that has a list of selection based on a query with a where clause clause that refers to a column in the original SQL query.

    The situation is, I have a table that stores the client_id, source_id, and build_id, lets call it client_source. I have a second table, build_source, containing source_id and build_id, one to many relations between the two (1 source_id could have build_id 1-7).

    Using a tabular presentation, I want to select the correspondent build_id to use in client_source, but the selection list should contain only the build_id for this particular source_id of lines.

    Here is an example of the SQL source of tabular presentation;

    Select
    s.ROWID,
    s.CLIENT_ID,
    s.SOURCE_ID,
    APEX_ITEM. SELECT_LIST_FROM_QUERY (1, s.BUILD_ID,)
    "Select display b.build_id, b.build_id return.
    b build_source where b.source_id = s.SOURCE_ID ') lst
    of s client_source

    what I want to achieve, it's as source_id "BOLD" match fields. When the query is built this way, I get an error of "invalid identifier" Oracle on s.SOURCE_ID during execution.

    Is there some special tags to be used to refer to the external column? I must be missing something because this looks like a pretty mundane problem.

    I am running on 4.1.0.00.32, on an Oracle 10 g release 10.2.0.4.0 Server Express request.


    I look forward to useful responses!


    See you soon,.
    Jason

    Published by: 1005131 on May 9, 2013 19:02

    Your selection by query list receives a static SQL. That SQL can't "see" the value of your s.source_id.
    But it would work like this:
    where b.source_id = ' | s.SOURCE_ID)

    You would be the value for the SQL concatenation. It is not ideal, but it will work.

    Jorge

  • Select the list with the list of dynamic values with more than 4000 tank of query

    Hello

    I have no application where users can store SQL queries in a CLOB column. This query is then used to populate the list, select a dynamic element through LOV. Following the code returns the query for dynamic LOV used to populate the select list. It works fine except when the length of the lv_sqlStatement becomes more than 4000 characters. Then application crashes with "ORA-06502: PL/SQL: digital or value error: character string buffer too small" when Select the list item rendering.

    Any ideas how to get around this problem? Any help is appreciated. Do not say to them to write shorter than 4000 queries because I can't (it's operational requirements).

    DECLARE
    lv_sqlStatement end_user_set.sql_statement%type;
    BEGIN
    lv_sqlStatement: =: P2_SQL_STATEMENT;
    return ' select the label, value of (' | lv_sql_statement | t ')
    To_char (t.value) if not in (select value from end_user_set_member eusm)
    where eusm. EUSRSET_ID = ' | : P2_EUSRSET_ID | ')';
    END;

    I just blogged about this problem and posted a solution. See this announcement:

    http://www.deneskubicek.blogspot.de/2013/03/select-list-with-dynamic-lov-and-Ora.html

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Apress.com/9781430235125
    http://Apex.Oracle.com/pls/Apex/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

Maybe you are looking for

  • Satellite A300D-15B - where can I buy HARD drive tray/caddy?

    Anyone know where I can buy a basket / drawer in England so I can get a second hard drive into the empty Bay in my laptop? Thanks in advance. Col

  • Are published network shared variable write &amp; read Atomic actions

    Hello I have a very basic question about shered (published network) variable. I think I know the answer already, but since I couldn't find in my documentation, I thought that it is more prudent to request... Are reading and writing on a shared variab

  • Mrs. mouse software keyboard XP and wireless both cause popups

    MS wireless mouse and the software keyboard XP that both make the pop-up windows that says that their non-plug-and-play drivers have not passed test of Windows Journal EACH time my laptop Toshiba is started. The mouse and keyboard work just fine, eve

  • Coding help - copy the date and the subject of the e-mail

    If I wanted to create a menu button that allows you to copy the object (and possibly date) of the email message that is highlighted, it is extremely difficult to achieve? I was told that the BIS, it is very delicate. Thanks for any help

  • MWI on duplicate extensions

    I have a client with a centralized call processing model, without the site to another component. As a result, they have extensions twice in the entire company. How can I set the unit to turn on the correct MWI when there is more than one instance of