Helps to find employees in each Department with pay the lowest

If I use the from employees of a hr schema table. I want to find the last_name, salary and employee department_id for employees with min (salary) for each Department

EMPLOYEES / / DESC:

ame                               Null               Type

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

EMPLOYEE_ID NOT NULL NUMBER (6)

FIRST NAME VARCHAR2 (20)

LAST_NAME NOT NULL VARCHAR2 (25)

EMAIL NOT NULL VARCHAR2 (25)

PHONE_NUMBER VARCHAR2 (20)

HIRE_DATE NOT NULL DATE

JOB_ID NOT NULL VARCHAR2 (10)

SALARY NUMBER (8.2)

COMMISSION_PCT NUMBER (2.2)

MANAGER_ID NUMBER (6)

DEPARTMENT_ID NUMBER 4

Here's what I used

Select last_name, salary, department_id from employee

where wages (select min (salary) of the Group of employees by department_id)

order by department_id;

However, it gives me the employees in each Department with a min wage equal to ANY min wage, even from other departments.

Just please give me a suggestion on this rewrite?

Hello

2776946 wrote:

... Here's what I used

Select last_name, salary, department_id from employee

where wages (select min (salary) of the Group of employees by department_id)

order by department_id;

...

You have diagnosed the problem exactly!  It is not enough to see if the wage of the employees table corresponds to a salary of the subquery; you need to check if the salary and the department_id both match.  Then change the subquery to return the salary both the department_id and compare the two, like this:

SELECT name, salary, department_id

Employees

WHERE () salary, department_id) )

SELECT MIN (salary)

department_id

Employees

GROUP BY department_id

)

ORDER BY department_id;

Apart from formatting, parts in Redare the only changes from what you have posted.

Tags: Database

Similar Questions

  • update of the commission of 6 percent of the employees in each Department, who got less pay

    How to upgrade add 6% commission to the salary of the employee in each Department, which received less pay

    Vinodh

    ora_1978 wrote:

    create table emp (number of eno, ename varchar2 (20), number of salary, number of dno);

    Insert into emp values(1,'john',1000,10);

    Insert into emp values(2,'smith',2000,10);

    Insert into emp values(3,'bill',5000,20);

    Insert into emp values(4,'mary',6000,20);

    Insert into emp values(5,'charles',1500,20);

    Insert into emp values(4,'mary',2000,30);

    Insert into emp values(4,'patrick',4500,30);

    create table dept (number of dno, dname varchar2 (10));

    Insert into dept values(10, 'HR');

    Insert into dept values(20, 'IT');

    Insert into dept values(30, 'ADMIN');

    How to add 6% commission to the salary of the employee table in each Department, which received less pay

    for example in the emp table for the dno 20 salary charles should get updated at 1500 * 1.6

    Vinodh

    Assuming that the two last emp records have 6 and 7 of Brian eno (and not 4 as you have your copy and paste error)...

    You can identify the records with the minimum in each Department as...

    SQL > ed
    A written file afiedt.buf

    1 Select keep (dense_rank of first order of salary) of the min (eno) as min_eno
    2 of t_emp
    3 * Group of dno
    SQL > /.
    MIN_ENO
    ----------
    1
    5
    6

    3 selected lines.

  • I need help to find a way to correct or update the drivers for two DVDs that I have on my PC. Device Manager indicates that they are missing or have been corrupted, and they are a product of microsoft.

    I tried to play a number of different disc, both DVD players and nothing seem to work.

    Your CD/DVD drive is missing or is not recognized by Windows or other programs:

    http://support.Microsoft.com/kb/982116

    Your CD or DVD drive cannot read or write media - Fix It:
    http://support.Microsoft.com/mats/cd_dvd_drive_problems

  • Query help - to get the number of employees joined on each month regardless of the year

    Hi all

    I wrote the code below for number of employees joined each month regardless of the year of the employee table. But I couldn't get the result. Kindly help me where I'm wrong in my code,

    Select to_char (hiredate, 'my') as join, count (empno) under the number

    WCP

    To_char Group (hiredate, 'my')

    After having count (empno) > 1;

    Your application displays the list of months (regardless of the year) where more than one employee was engaged with number of emplyees hired this month here. If you want months even if nobody was hired months thast, you emp table outer join to the list of every month:

    with t as)

    Select the level m

    of the double

    connect by level<=>

    )

    Select to_char (to_date (TM, 'mm'), 'my') Lun,

    Count (e.empno) cnt

    t

    left join

    E EMP

    on Tahina = to_char (e.hiredate, 'mm')

    Group of Tahina

    order of Tahina

    /

    MY CNT
    --- ----------
    1 jan
    February 2
    Mar 0
    Apr 2
    May 2
    1 Jun
    July 0
    August 0
    2 sep
    Oct 0
    1 nov

    MY CNT
    --- ----------
    Dec 3

    12 selected lines.

    SQL >

    SY.

  • I have a desktop white with all the icons and the taskbar, but cannot set the background.

    original title: I have a white desktop with all icons and task bar, but can't set a background. Nothing happens when I right click on the desktop to adjust only the properties please help

    We have a white desk with all the icons and taskbar. Everything I've looked up tells me to enable desktop but nothing happens when I right click so I'm unable to get the properties of office, I also tried to do system restore and also a reactivation on the desktop but nothing. Please help any suggestions would be helpful.

    Hello Carlapalsrok,

    Thanks for your post.  You experience this problem on all user accounts?  If you have not tested, try the following:

    Click Start > right click on my computer > select Manage

    Expand local users and groups

    Click on the users folder > in the right pane, right-click and select new users

    Fill in the appropriate data to create a new user account.

    To disconnect from the computer and log on as the new user

    You still see the white background?

    We can't wait to hear back on your part.

    See you soon

  • How to choose the Department with employees in the same line?

    Hello world

    I need to make this request,

    Suppose we have 2 departments with n used on each Department

    I need to select the departments with only 2 employees in the same line, example here

    Department Name of Department Employee1 Employee2
    10HUMAN RESOURCESMarcSteve
    20HEPaul
    30New Department
    40FinanceJeanMichael

    This query below did not work because it only displays the first employee, but I need to display 2 employees (same as the above table)

    select
    deptno,
    (select ename from emp, dept where rownum =1 and emp.deptno = dept.deptno) employee1,
    (select ename from emp, dept where rownum = 2 and emp.deptno = dept.deptno) employee2
    
    from dept;
    
    

    ...

    I did this, but with the function returning the Emp2Dep1 Emp1Dep1

    function get_ename(p_dept number,p_col number)
    return varchar2
    is
        v_ename varchar2(4000);
        v_first boolean := true;
    BEGIN
            select ename
                  into v_ename
                  from
                      (
                      select ename, rownum as rn
                      from (
                            select ename
                            from emp ,dept
                            where    emp.deptno        = p_dept
                            order by 1 asc
                            )
               
                      )
                  where rn = p_col;       
              
    
         return v_ename;
    END;
    
    

    and simply put

    select
    get_ename(deptno ,1 ) employee1,
    get_ename(deptno ,2 ) employee2
    from dept;
    
    

    Is there a better way to do it?

    NB: database 11g

    Thank you

    Select the Department, employee1, employee2

    (select Department, name, cnt

    (name, department, row_number (select) at the NTC (partition by order of the Department by null)

    employees

    )

    where NTC<=>

    )

    Pivot (max (name) of the cnt (1 as employee1, 2 as employee2))

    order by Department

    DEPARTMENT EMPLOYEE1 EMPLOYEE2
    10 Marc Steve
    20 Paul -
    30 - -
    40 Jean Michael
    50 Alpha Beta

    Concerning

    Etbin

  • Each time after clicking the icon of user account on windows xp to change a password is crashes with this error message: Microsoft (R) HTML Application host has encountered a problem and needs to close.

    Each time after clicking the icon of user account on windows xp to change a password is crashes with this error message: Microsoft (R) HTML Application host has encountered a problem and needs to close.

    There is a Microsoft Knowledge base article which sets up a few steps to perform in the computer in order to solve the problem you are experiencing, read the article that you find on the link I am mentioning below and see if it helps the measures mentioned:

    http://support.Microsoft.com/kb/919751

  • Help to find the best way to interior design (Nested Loops of sliders?)

    Oracle 11G

    First here the table I work with, for example data

    ID FID ANNOTATION DESIGNATION LOW HIGH SEQ
    11008755360FC1053, 81-82FC105381821
    21008755360XD, 3-24XD3242
    31008756293FC1053, 81-82FC105381821
    41008756293XD, 3-24XD3242

    Each FID is a different line, these two lines are connected physically, that's why I've shown them here on the table. Each line has a 'meter', in this case, each line has 2 lines of account that are the same.

    cableExample.png

    From there, we can say that FC1053, 81 and 82 are connected between the 2 cables. XD DESIGNATION means that cables are connect not really so I can't ignore those.

    We have a different way to show that they connect other than only those data and I need to connect each other too much. For this I need the Info

    FID1 LOW HIGH FID2
    100875536081821008756293

    So my first design was the hepatitis hase sliders 2 with the data in the table, as shown above. I would then have a nested loop. The first slider to select the first record, then go down to the second loop where I compare all other records the first record and then go back in the outer loop to move to the next record, then return once again to the inner loop to compare the values again.

    LOOP1

    LOOP 2

    If LOOP1. IDF! LOOP2 =. IDF THEN

    IF LOOP1. ANNOTATION = LOOP2. ANNOTATION THEN

    -CONNECT THE DATA

    ON THE OTHER

    IF LOOP1. DESCRIPTION = LOOP2. DESIGNATION THEN

    IF LOOP2. LOW BETWEEN LOOP1. LOW AND LOOP1. THEN HIGH

    IF LOOP2. HIGH BETWEEN LOOP1. LOW AND LOOP1. HGH THEN

    -CONNECT THE DATA

    END IF;

    END IF;

    END IF;

    END IF;

    END IF;

    END LOOP;

    -Open and close done to reset the cursor to the front/top

    CLOSE CURSOR LOOP2;

    OPEN CURSOR LOOP2

    END LOOP;

    The problem with this approach is once the outside loop moves the next value of the IDF, that logic will connect them once again, but this time with the FIDs reverse which is essentially the same thing as it does not matter the direction in which they are connected. I almost feel that once I found the link I need to remove that line from the cursor (which isn't possible).

    FID1 LOW HIGH FID2
    100875536081821008756293
    100875629381821008755360

    I was able to

    1. make a list of all those I have connected and check against that

    2 use some kind of collection

    3. use a temporary table to hold the data

    4 something that I have not yet thought

    I really appreciate in advance for any help I get.

    If your query mapping is correct, this is the result of your query with the addition of the values of sum for the strand/down running.  Manually change the incorrect in the output bit numbers so that we can move on to find another solution.

    with gc_count like)

    Select

    Sum(current_high-current_low+1) on strand_high (g3e_fid seq order partition),

    Sum(current_high-current_low+1) more (partition of g3e_fid order of seq).

    strand_low (current_high-current_low),

    t.* from b$ gc_count t

    )

    Select

    a.g3e_fid, a.current_designation, a.current_low, a.current_high, a.strand_high, a.strand_low,

    b.g3e_fid, b.current_designation, b.current_low, b.current_high, b.strand_high, b.strand_low

    gc_count a, gc_count b

    where a.g3e_fid in (1008757155,1008757159,1009999655)

    and in b.g3e_fid (1008757155,1008757159,1009999655)

    and a.g3e_fid > b.g3e_fid

    and ((a.count_annotation = b.count_annotation)

    or (a.current_designation = b.current_designation

    and a.current_low b.current_low and b.current_high and a.current_high between b.current_low and b.current_high)

    order of b.seq

    /

    G3E_FID CURRENT_DESIGNATION CURRENT_LOW CURRENT_HIGH STRAND_HIGH STRAND_LOW G3E_FID CURRENT_DESIGNATION CURRENT_LOW CURRENT_HIGH STRAND_HIGH STRAND_LOW

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

    GAGA GAGA 1008757159 1008757155 1 1 2 2 1 2 2 1

    1008757159 3 8 8 3 1008757155 3 8 8 3 F1DM F1DM

    1008757159 9 10 10 9 1008757155 9 10 10 9 F2 F2

    1008757159 11 14 14 11 1008757155 11 14 14 11 F1DM F1DM

    1009999655 17 18 6 5 1008757155 15 18 18 15 F2 F2

    1008757159 15 16 16 15 1008757155 15 18 18 15 F2 F2

    1009999655 21 24 4 1 1008757155 21 24 24 21 F2 F2

    7 selected lines.

    Elapsed time: 00:00:00.06

  • Display the name of the Department and employees in this Department

    Hi all

    I want to display the name of the Department and employees in this Department in a single line. Can you please help me to do so.

    Oracle version : 9.2.0.8

    create table emp
    (varchar2 (100) number of ename, empno, dept_id number);

    create table dept
    (dept_id number, dept_name varchar2 (100));

    Start
    insert into emp values (100, 'Raghu', 10);
    insert into emp values (101, 'Nathalie', 10);
    insert into emp values (102, 'Sai', 10);
    insert into emp values (103, "Riquet", 20);
    insert into emp values (104, 'Radha', 20);
    insert into emp values (105, "Bika", 30);
    insert into emp values (106, 'Satish', 30);
    insert into emp values (107, 'Emma', 30);
    end;

    Start
    insert into dept values (10, 'Sales');
    insert into dept values (20, 'Marketing');
    insert into dept values (30, 'accounts');
    end;

    Expected results
    *********************
    dept_name employees
    -------------- ----------------------
    Sale of Raghu, Tedla, Sai
    Marketing Ramesh, Radha
    Accounts Bilodeau, Satish, James

    Thank you
    Rambeau
    select dept_name,
    max(sys_connect_by_path(ename,',')) employess
    from (select dept_name,ename,
          row_number() over(partition by emp.dept_id
          order by empno) r
          from emp,dept
          where emp.dept_id = dept.dept_id)
    start with r=1
    connect by prior r+1=r
           and prior dept_name=dept_name
    group by dept_name;
    
  • How the page break to each Department and calculate totals for Department

    I have a stored procedure that queries our sql database and returns the name of the employee, their Department, and a few other calculations. I use CFDocument to create a table and view the results. Here's the code that does this (see below) what I have to do is find a way to create a page break after that I have show a total for each column in each Department. My questions are so

    1. How can I insert a page break after the end of each service
    2. just above the page break, how to calculate the totals for the Department and display them?

    < cfdocument format = "pdf" >
    < table width = "650" border = "1" >
    < cfoutput query = "getResults" >
    < b >
    < td > #EmpName # < table >
    < td > #Dept # < table >
    < td > #JobType # < table >
    < td > #NonBill # < table >
    < td > #NonBillMeter # < table >
    < td > #NumberFormat ((NonBillPercent*100),.00) # < table >
    < td > #Bill # < table >
    < td > #BillMeter # < table >
    < td > #NumberFormat ((BillPercent*100),.00) # < table >
    < /tr >
    < / cfoutput >
    < /table >
    < / cfdocument >

    If I remember correctly, the tag you want is cfdocumentitem. Also, you want to check the attribute of cfoutput group.

    The details are in the cfml reference manual. If you do not have one, has the internet.

  • Help to find my stolen iPhone more than 6 s

    Help, please!

    I bought the iPhone 6 s more last month. I am new for ios. While I did not turn on find my iPhone on my mobile. Now it is has been stolen by someone.

    Please please please help me find my phone.

    I have an IMEI: 353288074718846

    Can you please let me know if it is possible to change my mobile IMEI number of thief?

    I have raised a case with the police. But they are not considered priority.

    If it is possible to turn on find my iphone via webpage (iCloud or Apple ID)?

    So please help me to trace my mobile

    I'm waiting for your good answer.

    If you have not enabled find my iPhone before losing the device, you can not activate it remotely.  You will not be able to track the device.  I recommend that you change any account information you have can have on the device (credit cards, passwords, email, etc.) unless you're confident, you had a strong password on the device.

  • redeclenchables out initial varaible on each trigger with delay

    I'm trying to implement a redeclenchables generation digital pulses of the train on 6363 PCIe with LabVIEW with the additional feature of an initial delay variable.

    For example:

    -J' have a fixed pulse train

    -After the 1st trigger, it is generated without delay

    -2nd after trigger, there is a delay of 10µs

    -Each subsequent trigger increases the delay of 10µs

    I tried to do by writing new samples to the digital output, which include an initial delay. Since it merely controls how the buffering is managed this does not seem to work reliable with reboot and redeclenchables ouput.

    Is there another way to do this using a perhaps additional internal counter for the generation of delay?

    Thank you

    Christoph

    I would look at using an additional counter that your delay generator.  There is a counter property called

    Delay 'auto increment Count', which lets specify you such a regularly increasing.  Here is one

    DevZone article and example that should help get you started.

    The idea is that the extra meter comes between your initial trigger signal and the

    pulse train finish that you want to generate.  The additional counter made its own triggered impulse

    with time growing after the initial trigger and your finite pulse train gets triggered by

    This additional counter output.

    -Kevin P

  • Need help to find and install the game Chess Titans Windows Vista for XP

    Need help to find and install the game Chess Titans Windows Vista for XP

    Hi SBOYDC130guy,

    We will not be able to install titan of failures on windows XP because it is designed for Windows Vista and Windows 7 and it's built-in game.

    With regard to:

    Samhrutha G S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Please help me find my password for my email account

    Original title:
    Please help me find my password * address email is removed from the privacy *, I can't go more than 10 days, is my other email * address email is removed from the privacy *.
    -----

    Please help me find my password * address email is removed from the privacy *, you can send the password information to my alternative * address email is removed from the privacy *. Thank you!

    Hotmail account?

    Please carefully follow all of the steps on the Recovery Windows LiveID account Help Page.

    Sorry, we can not help you with your Hotmail account number in the Microsoft answers Forums.

    Kind regards.

  • Ran Malwarebytes & two threats were each one with the same name: PUM. Disabled.SecurityCenter. fact that associated with MSSE PUM & the boxes unchecked in MS security Center.

    Original title: PUM. Disabled.SecurityCenter

    I recently removed "patch system" of my Dell computer XP. Malwarebyte s was the only software to do. MSSE caught, but couldn't fix it. I then updated & ran MSSE on my Toshiba - no threats not found. I then ran Malwarebytes & two threats were each one with the same name: PUM. Disabled.SecurityCenter both at the Date of the registry in HKLM\SOFTE\Microsfot\SecurityCenter\AntiVirusDisableNotify & HKLM\SOFTWARE\Microsfot\securityCenterFirewallDisableNotify.  These two have been listed bad: Good (0) (1).  In the Malwarebytes wesite, I read that this has something to do with MSSE. In a commentary, he says it occurs if, in the MS Security Center, the notification "Notify me if my computer might be at risk because of my virus protection software settings" is unchecked.  I then went ahead & check all 3, firewalls, viruses & automatic updates. My computer seems to work well, except that the fan runs all the time (there are a lot of processes running & the CPU usage is very--often 100%, but the computer works fast).

    My questions are: 1) the PUM associated MSSE & the boxes unchecked in MS security Center; (2) should I click on "ignore" in the Malwarebytes scan? 3) was right to check all the boxes in the center of security - "altert me if my computer may be at rist b/c of my xxx software settings?  Thanks in advance for your help.

    PC fan2

    Hello

    (1) is associated with MSSE PUM & the boxes unchecked in MS security Center;

    The following thread might answer this question: http://forums.malwarebytes.org/index.php?showtopic=69859

    (2) should I click on "ignore" in the Malwarebytes scan?

    Yes

    3) was right to check all the boxes in the center of security - "altert me if my computer may be at rist b/c of my xxx software settings?

    Only, run antivirus software at the same time. Firewall must be performed, evil-ware bytes can be run at your pleasure.

Maybe you are looking for