0% found this document useful (0 votes)
49 views1 page

Salary 4 Type Queries

The document contains SQL queries. Query 1 finds the second highest salary from the Employee table. Query 2 also finds the second highest salary. Query 3 finds employees with the second highest unique salary. Query 4 finds the second highest salary by ordering the salaries in descending order, limiting to the top 2 salaries, and then ordering and limiting the result to the highest of those 2 salaries. The last statement updates the email field of the user table by removing any '/' or '-' characters from the email.

Uploaded by

Jenna Coleman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

Salary 4 Type Queries

The document contains SQL queries. Query 1 finds the second highest salary from the Employee table. Query 2 also finds the second highest salary. Query 3 finds employees with the second highest unique salary. Query 4 finds the second highest salary by ordering the salaries in descending order, limiting to the top 2 salaries, and then ordering and limiting the result to the highest of those 2 salaries. The last statement updates the email field of the user table by removing any '/' or '-' characters from the email.

Uploaded by

Jenna Coleman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

INSERT INTO `employee` (`emp_id`, `emp_name`, `salary`, `department_id`) VALUES (NULL,

'Ram', '50000', '1'), (NULL, 'Syam', '80000', '2'), (NULL, 'Ghanshyam', '30000', '1'),

(NULL, 'Shiva', '100000', '1');

INSERT INTO `department` (`department_id`, `department_title`) VALUES (NULL, 'IT'), (NULL,

'Management ');

1) SELECT MAX(salary) FROM Employee WHERE Salary NOT IN ( SELECT


Max(Salary) FROM Employee);

2) SELECT MAX(Salary) From Employee WHERE Salary < ( SELECT Max(Salary)


FROM Employee);

3) SELECT emp_id, Salary FROM Employee e WHERE 2=(SELECT COUNT(DISTINCT


Salary) FROM Employee p WHERE e.Salary<=p.Salary)

4) SELECT Salary FROM (SELECT Salary FROM Employee ORDER BY salary DESC
LIMIT 2) AS Emp ORDER BY salary LIMIT 1;

update user

set email = replace(email,'/-','')

You might also like