Search
 
SCRIPT & CODE EXAMPLE
 

SQL

get max salary from each department sql

--Find out the name of top earner in each departments
--Output has Name, Department name and max salary of the department

SELECT E.FIRST_NAME , D.DEPARTMENT_NAME, E.SALARY
FROM EMPLOYEES E
JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
WHERE SALARY IN(SELECT MAX(E.SALARY)
FROM EMPLOYEES E
JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
GROUP BY DEPARTMENT_NAME);
Comment

max 3 salary in sql

SELECT salary, first_name, last_name FROM employees
ORDER BY salary DESC LIMIT 3;
Comment

how to get max salary in each department in sql

SELECT firstname, MAX(salary)
FROM department d LEFT OUTER JOIN employee e
ON (d.department_id = e.department_id)
GROUP BY department_id; 
Comment

how to find max and min salary in sql

SELECT MAX(SALARY) FROM EMPLOYEES
UNION
SELECT MIN(SALARY) FROM EMPLOYEES;
Comment

first max salary in sql

SELECT first-name
FROM employees
WHERE salary = (SELECT MAX(salary) FROM employees);
Comment

min and max salary and name in sql

SELECT FIRST_NAME , SALARY
FROM EMPLOYEES
WHERE SALARY IN (SELECT MAX(SALARY)AS RESULT FROM EMPLOYEES
UNION
SELECT MIN(SALARY)AS RESULT FROM EMPLOYEES);
Comment

PREVIOUS NEXT
Code Example
Sql :: drush SQLSTATE[HY000] [2002] No such file or directory 
Sql :: datagrip exec 
Sql :: union vs union all in sql 
Sql :: sqlite unix timestamp 
Sql :: print boolean in plsql 
Sql :: mysql find max value row 
Sql :: create db table 
Sql :: mysql if statement in where clause 
Sql :: query to find third highest salary 
Sql :: set column width in sqlplus 
Sql :: mysqli auto increment id 
Sql :: mysql create table if not exists 
Sql :: sqlalchemy get ids 
Sql :: SQL Query to delete all the tables in a database 
Sql :: having in sql server 
Sql :: what is denormalization in sql 
Sql :: select only distinct values another table 
Sql :: convert negative to positive in sql 
Sql :: how to find sql server installation folder 
Sql :: oracle ora-00054 how to unlock 
Sql :: mysql default -temp password 
Sql :: sqlite create record 
Sql :: calculer pourcentage mysql 
Sql :: how to get second highest salary in each department in sql 
Sql :: sqlalchemy query sql compiled 
Sql :: how to login to mysql as normal user in ubuntu 
Sql :: dump db only triggers mysql 
Sql :: longtext sql 
Sql :: postgres copy table 
Sql :: sql creating tables 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =