Results 1 to 2 of 2

Thread: I want deptno and sal who are having highest salary

  1. #1
    Geek_Guest
    Guest

    I want deptno and sal who are having highest salary

    Hi folks,

    I've a scenario my source table having four columns like, ID,NAME,SAL,DEPTNO and my target table having only two columns i'e DEPTNO and SAL. So i want deptno and sal who are having highest salary among all depts. like
    ID NAME SAL DEPTNO TARGET
    101 XXX 1000 10 DEPTNO SAL
    102 YYY 2000 10 10 7000
    103 ZZZ 3000 20
    104 AAA 7000 10
    105 BBB 4000 30

    I appriciate you for fast response.

    Question asked by visitor ravi kumar


  2. #2
    Expert Member
    Join Date
    Jun 2006
    Answers
    410

    Re: I want deptno and sal who are having highest salary

    if you want highest salary for each department then you need to run the following query,
    select deptno,max(sal) from emp
    group by deptno

    If you want deptartment id and maximum salary of depts whose maximum salary is maximum irrespective of dept then run the following query,

    select distinct deptno,sal from emp
    where sal = (select max(sal) from emp)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact