SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE employees ( id INT, name VARCHAR(50), department VARCHAR(50), salary INT ); INSERT INTO Employees (Id, Name, Salary, department) VALUES (1, 'Ivanov', 100000, 'SAPIENS'), (2, 'Petrov', 100000, 'SAPIENS'), (3, 'Sidorov', 130000, 'TECHNOLOGIES'), (4, 'Korotkov', 120000, 'TECHNOLOGIES'), (5, 'Filev', 90000, 'SAPIENS'), (6, 'Smirnov', 125000, 'REVOLT'), (7, 'Godov', 125000, 'REVOLT') ; SELECT (AVG(ROW_NUMBER) + SUM(RANK) + SUM(DENSE_RANK)) FROM (SELECT DEPARTMENT , SALARY , ROW_NUMBER() OVER(PARTITION BY DEPARTMENT ORDER BY SALARY DESC) AS 'ROW_NUMBER' , RANK() OVER(PARTITION BY DEPARTMENT ORDER BY SALARY DESC) AS 'RANK' , DENSE_RANK() OVER(PARTITION BY DEPARTMENT ORDER BY SALARY DESC) AS 'DENSE_RANK' FROM EMPLOYEES) AS T1 WHERE DEPARTMENT LIKE '%A__E%';

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear